結果

問題 No.1722 [Cherry 3rd Tune C] In my way
ユーザー AsahiAsahi
提出日時 2023-02-06 12:58:29
言語 Java21
(openjdk 21)
結果
AC  
実行時間 237 ms / 2,000 ms
コード長 914 bytes
コンパイル時間 2,590 ms
コンパイル使用メモリ 73,376 KB
実行使用メモリ 59,948 KB
最終ジャッジ日時 2023-09-18 00:46:27
合計ジャッジ時間 10,032 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
55,664 KB
testcase_01 AC 186 ms
55,956 KB
testcase_02 AC 223 ms
59,492 KB
testcase_03 AC 225 ms
59,040 KB
testcase_04 AC 215 ms
57,284 KB
testcase_05 AC 206 ms
56,712 KB
testcase_06 AC 170 ms
55,980 KB
testcase_07 AC 189 ms
55,888 KB
testcase_08 AC 229 ms
59,228 KB
testcase_09 AC 205 ms
56,396 KB
testcase_10 AC 155 ms
56,044 KB
testcase_11 AC 231 ms
59,252 KB
testcase_12 AC 230 ms
58,920 KB
testcase_13 AC 237 ms
59,948 KB
testcase_14 AC 231 ms
59,624 KB
testcase_15 AC 233 ms
59,664 KB
testcase_16 AC 233 ms
59,648 KB
testcase_17 AC 226 ms
59,308 KB
testcase_18 AC 236 ms
59,684 KB
testcase_19 AC 234 ms
59,660 KB
testcase_20 AC 233 ms
59,764 KB
testcase_21 AC 131 ms
55,596 KB
testcase_22 AC 130 ms
55,700 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;
import java.math.*;
// import java.util.stream.Stream;

class Main{
    static BufferedReader buff = new BufferedReader(new InputStreamReader(System.in));
    static StringTokenizer st;
    static PrintWriter output = new PrintWriter(System.out);
    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws IOException{
        int n = sc.nextInt();
        int m = sc.nextInt();
        int [] x = new int[n];
        TreeSet<Integer> wall = new TreeSet<>();
        for(int i=0;i<n;i++) x[i] = sc.nextInt();
        for(int i=0;i<m;i++) wall.add(sc.nextInt());
        for(int i=0;i<n;i++) {
            if(wall.higher(x[i]) == null) output.println("Infinity");
            else {
                int next_wall = wall.higher(x[i]);
                output.println(next_wall-x[i]);
            }
        }
        output.flush();
    }
}
0