結果

問題 No.514 宝探し3
ユーザー jp_stejp_ste
提出日時 2017-05-16 20:40:47
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 1,011 bytes
コンパイル時間 2,210 ms
コンパイル使用メモリ 77,928 KB
実行使用メモリ 73,076 KB
平均クエリ数 0.25
最終ジャッジ日時 2023-09-23 14:04:19
合計ジャッジ時間 6,161 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 176 ms
73,076 KB
testcase_01 TLE -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    static ArrayList<Point> list = new ArrayList<>();
    
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        System.out.println(0 + " " + 0);
        long d1 = scan.nextInt();
        possiblePoints(d1);
        System.out.println(d1 + " " + 0);
        long d2 = scan.nextInt();
        serchPoint(d1, d2);
    }
    
    static void possiblePoints(long d) {
        for(long x=0; x<=d; x++) {
            long y = d-x;
            list.add(new Point(x,y));
        }
    }
    
    static void serchPoint(long d1, long d2) {
        Point p1 = new Point(d1, 0);
        for(Point p2: list) {
            long d = Math.abs(p1.x - p2.x) + Math.abs(p1.y - p2.y);
            if(d == d2) {
                System.out.println(p2.x + " " + p2.y);
                return;
            }
        }
    }
}

class Point {
    long x,y;
    Point(long x, long y) {
        this.x = x;
        this.y = y;
    }
}
0