結果

問題 No.1722 [Cherry 3rd Tune C] In my way
ユーザー Asahi
提出日時 2023-02-06 12:58:29
言語 Java
(openjdk 23)
結果
AC  
実行時間 225 ms / 2,000 ms
コード長 914 bytes
コンパイル時間 2,213 ms
コンパイル使用メモリ 76,740 KB
実行使用メモリ 44,208 KB
最終ジャッジ日時 2024-07-04 17:52:33
合計ジャッジ時間 7,950 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

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