AtCoder Beginner Contest 019

Submission #346129

Source codeソースコード

import java.io.*;
import java.util.*;

public class Main {
    void run() {
        int N = readInt();
        int maxD = 0;
        int maxV = -1;
        for (int i = 2; i <= N; i++) {
            System.out.println(String.format("? %d %d", 1, i));
            int d = readInt();
            if (maxD < d) {
                maxD = d;
                maxV = i;
            }
        }
        int ans = 0;
        for (int i = 1; i <= N; i++) {
            if (i == maxV) continue;
            System.out.println(String.format("? %d %d", maxV, i));
            int d = readInt();
            if (ans < d) {
                ans = d;
            }
        }
        System.out.println(String.format("! %d", ans));
    }

    public static void main(String[] args) {
        new Main().run();
    }

    // flush automatically iff you call `println` or `printf` or `format`.
    PrintWriter sysout = new PrintWriter(System.out, true);

    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer buffer = new StringTokenizer("");

    String read() {
        if (!buffer.hasMoreTokens()) {
            try {
                buffer = new StringTokenizer(in.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return buffer.nextToken();
    }

    int readInt() {
        return Integer.parseInt(read());
    }

    long readLong() {
        return Long.parseLong(read());
    }

    double readDouble() {
        return Double.parseDouble(read());
    }

    String readLine() {
        buffer = new StringTokenizer("");
        try {
            return in.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}

Submission

Task問題 D - 高橋くんと木の直径
User nameユーザ名 arosh
Created time投稿日時
Language言語 Java (OpenJDK 1.7.0)
Status状態 AC
Score得点 100
Source lengthソースコード長 1847 Byte
File nameファイル名
Exec time実行時間 574 ms
Memory usageメモリ使用量 21568 KB

Test case

Set

Set name Score得点 / Max score Cases
Sample - subtask0_0.txt
Subtask1 20 / 20 subtask1_0.txt,subtask1_1.txt,subtask1_10.txt,subtask1_11.txt,subtask1_12.txt,subtask1_13.txt,subtask1_14.txt,subtask1_15.txt,subtask1_16.txt,subtask1_17.txt,subtask1_18.txt,subtask1_19.txt,subtask1_2.txt,subtask1_20.txt,subtask1_3.txt,subtask1_4.txt,subtask1_5.txt,subtask1_6.txt,subtask1_7.txt,subtask1_8.txt,subtask1_9.txt,subtask0_0.txt
All 80 / 80 subtask0_0.txt,subtask1_0.txt,subtask1_1.txt,subtask1_10.txt,subtask1_11.txt,subtask1_12.txt,subtask1_13.txt,subtask1_14.txt,subtask1_15.txt,subtask1_16.txt,subtask1_17.txt,subtask1_18.txt,subtask1_19.txt,subtask1_2.txt,subtask1_20.txt,subtask1_3.txt,subtask1_4.txt,subtask1_5.txt,subtask1_6.txt,subtask1_7.txt,subtask1_8.txt,subtask1_9.txt,subtask2_0.txt,subtask2_1.txt,subtask2_10.txt,subtask2_11.txt,subtask2_12.txt,subtask2_13.txt,subtask2_14.txt,subtask2_15.txt,subtask2_16.txt,subtask2_17.txt,subtask2_18.txt,subtask2_19.txt,subtask2_2.txt,subtask2_3.txt,subtask2_4.txt,subtask2_5.txt,subtask2_6.txt,subtask2_7.txt,subtask2_8.txt,subtask2_9.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
subtask0_0.txt AC 461 ms 21276 KB
subtask1_0.txt AC 479 ms 21568 KB
subtask1_1.txt AC 481 ms 21400 KB
subtask1_10.txt AC 477 ms 21420 KB
subtask1_11.txt AC 479 ms 21436 KB
subtask1_12.txt AC 483 ms 21364 KB
subtask1_13.txt AC 476 ms 21552 KB
subtask1_14.txt AC 481 ms 21500 KB
subtask1_15.txt AC 484 ms 21376 KB
subtask1_16.txt AC 471 ms 21532 KB
subtask1_17.txt AC 471 ms 21420 KB
subtask1_18.txt AC 485 ms 21460 KB
subtask1_19.txt AC 483 ms 21400 KB
subtask1_2.txt AC 474 ms 21568 KB
subtask1_20.txt AC 454 ms 21292 KB
subtask1_3.txt AC 479 ms 21480 KB
subtask1_4.txt AC 561 ms 21428 KB
subtask1_5.txt AC 521 ms 21472 KB
subtask1_6.txt AC 574 ms 21412 KB
subtask1_7.txt AC 485 ms 21496 KB
subtask1_8.txt AC 476 ms 21488 KB
subtask1_9.txt AC 477 ms 21564 KB
subtask2_0.txt AC 476 ms 21452 KB
subtask2_1.txt AC 481 ms 21464 KB
subtask2_10.txt AC 486 ms 21476 KB
subtask2_11.txt AC 479 ms 21424 KB
subtask2_12.txt AC 473 ms 21416 KB
subtask2_13.txt AC 475 ms 21496 KB
subtask2_14.txt AC 493 ms 21476 KB
subtask2_15.txt AC 479 ms 21492 KB
subtask2_16.txt AC 476 ms 21416 KB
subtask2_17.txt AC 476 ms 21428 KB
subtask2_18.txt AC 481 ms 21488 KB
subtask2_19.txt AC 476 ms 21468 KB
subtask2_2.txt AC 478 ms 21564 KB
subtask2_3.txt AC 476 ms 21412 KB
subtask2_4.txt AC 471 ms 21452 KB
subtask2_5.txt AC 473 ms 21516 KB
subtask2_6.txt AC 479 ms 21544 KB
subtask2_7.txt AC 479 ms 21500 KB
subtask2_8.txt AC 476 ms 21460 KB
subtask2_9.txt AC 480 ms 21548 KB