結果

問題 No.1722 [Cherry 3rd Tune C] In my way
ユーザー ripityripity
提出日時 2021-12-12 21:43:14
言語 Java21
(openjdk 21)
結果
AC  
実行時間 233 ms / 2,000 ms
コード長 927 bytes
コンパイル時間 5,091 ms
コンパイル使用メモリ 73,308 KB
実行使用メモリ 42,916 KB
最終ジャッジ日時 2023-09-28 15:13:32
合計ジャッジ時間 11,518 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
39,516 KB
testcase_01 AC 185 ms
40,724 KB
testcase_02 AC 225 ms
41,900 KB
testcase_03 AC 226 ms
41,716 KB
testcase_04 AC 216 ms
41,872 KB
testcase_05 AC 201 ms
40,820 KB
testcase_06 AC 153 ms
39,780 KB
testcase_07 AC 193 ms
40,468 KB
testcase_08 AC 232 ms
42,112 KB
testcase_09 AC 185 ms
40,224 KB
testcase_10 AC 145 ms
40,072 KB
testcase_11 AC 223 ms
42,204 KB
testcase_12 AC 228 ms
42,584 KB
testcase_13 AC 222 ms
42,908 KB
testcase_14 AC 232 ms
42,460 KB
testcase_15 AC 232 ms
42,172 KB
testcase_16 AC 233 ms
42,732 KB
testcase_17 AC 231 ms
42,824 KB
testcase_18 AC 233 ms
42,916 KB
testcase_19 AC 230 ms
42,644 KB
testcase_20 AC 224 ms
42,580 KB
testcase_21 AC 121 ms
39,668 KB
testcase_22 AC 118 ms
39,652 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] X = new int[N];
        int[] Y = new int[M];
        for( int i = 0; i < N; i++ ) {
            X[i] = sc.nextInt();
        }
        
        for( int i = 0; i < M; i++ ) {
            Y[i] = sc.nextInt();
        }
        
        Arrays.sort(Y);
        for( int i = 0; i < N; i++ ) {
            int index = lowerBound(Y,X[i]);
            System.out.println( X[i] > Y[index] ? "Infinity" : Y[index]-X[i] );
        }
        
    }
    
	static int lowerBound ( int[] arr, int value ) {
		
		int high = arr.length-1;
		int low = 0;
		while( low < high ){
			int index = (high+low)/2;
			if( arr[index] < value ) {
				low = index+1;
			}else {
				high = index;
			}
		}
		
		return low;
		
	}
    
}
0