結果

問題 No.1722 [Cherry 3rd Tune C] In my way
ユーザー ks2mks2m
提出日時 2021-10-29 21:25:33
言語 Java21
(openjdk 21)
結果
AC  
実行時間 269 ms / 2,000 ms
コード長 597 bytes
コンパイル時間 2,158 ms
コンパイル使用メモリ 85,012 KB
実行使用メモリ 44,412 KB
最終ジャッジ日時 2024-04-16 14:01:33
合計ジャッジ時間 8,047 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
41,284 KB
testcase_01 AC 184 ms
42,132 KB
testcase_02 AC 241 ms
43,724 KB
testcase_03 AC 234 ms
44,052 KB
testcase_04 AC 225 ms
43,168 KB
testcase_05 AC 213 ms
42,576 KB
testcase_06 AC 166 ms
41,892 KB
testcase_07 AC 196 ms
42,888 KB
testcase_08 AC 248 ms
43,964 KB
testcase_09 AC 194 ms
43,000 KB
testcase_10 AC 169 ms
41,584 KB
testcase_11 AC 256 ms
44,272 KB
testcase_12 AC 256 ms
44,412 KB
testcase_13 AC 251 ms
44,376 KB
testcase_14 AC 269 ms
44,196 KB
testcase_15 AC 253 ms
44,100 KB
testcase_16 AC 240 ms
44,128 KB
testcase_17 AC 250 ms
43,984 KB
testcase_18 AC 247 ms
44,148 KB
testcase_19 AC 249 ms
44,396 KB
testcase_20 AC 254 ms
44,352 KB
testcase_21 AC 129 ms
41,056 KB
testcase_22 AC 135 ms
41,260 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
import java.util.TreeSet;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] x = new int[n];
		for (int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
		}
		TreeSet<Integer> y = new TreeSet<>();
		for (int i = 0; i < m; i++) {
			y.add(sc.nextInt());
		}
		sc.close();

		for (int i = 0; i < n; i++) {
			Integer a = y.higher(x[i]);
			if (a == null) {
				System.out.println("Infinity");
			} else {
				System.out.println(a - x[i]);
			}
		}
	}
}
0