結果

問題 No.1722 [Cherry 3rd Tune C] In my way
ユーザー tentententen
提出日時 2021-11-01 15:04:04
言語 Java21
(openjdk 21)
結果
AC  
実行時間 94 ms / 2,000 ms
コード長 1,468 bytes
コンパイル時間 2,671 ms
コンパイル使用メモリ 78,448 KB
実行使用メモリ 38,760 KB
最終ジャッジ日時 2024-04-18 11:07:59
合計ジャッジ時間 5,449 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
37,016 KB
testcase_01 AC 52 ms
37,360 KB
testcase_02 AC 73 ms
38,224 KB
testcase_03 AC 83 ms
38,356 KB
testcase_04 AC 79 ms
38,228 KB
testcase_05 AC 57 ms
37,408 KB
testcase_06 AC 49 ms
37,232 KB
testcase_07 AC 50 ms
36,988 KB
testcase_08 AC 90 ms
38,324 KB
testcase_09 AC 59 ms
37,316 KB
testcase_10 AC 50 ms
37,232 KB
testcase_11 AC 90 ms
38,364 KB
testcase_12 AC 88 ms
38,164 KB
testcase_13 AC 87 ms
38,480 KB
testcase_14 AC 89 ms
38,160 KB
testcase_15 AC 88 ms
38,760 KB
testcase_16 AC 86 ms
38,260 KB
testcase_17 AC 93 ms
38,512 KB
testcase_18 AC 77 ms
38,444 KB
testcase_19 AC 88 ms
38,480 KB
testcase_20 AC 94 ms
38,248 KB
testcase_21 AC 48 ms
37,136 KB
testcase_22 AC 48 ms
36,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] persons = new int[n];
        for (int i = 0; i < n; i++) {
            persons[i] = sc.nextInt();
        }
        TreeSet<Integer> hardles = new TreeSet<>();
        for (int i = 0; i < m; i++) {
            hardles.add(sc.nextInt());
        }
        StringBuilder sb = new StringBuilder();
        for (int x : persons) {
            if (x > hardles.last()) {
                sb.append("Infinity");
            } else {
                sb.append(hardles.higher(x) - x);
            }
            sb.append("\n");
        }
        System.out.print(sb);
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public String nextLine() throws Exception {
        return br.readLine();
    }
    
    public String next() throws Exception {
        if (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
}
0