結果
問題 |
No.1722 [Cherry 3rd Tune C] In my way
|
ユーザー |
![]() |
提出日時 | 2021-12-12 21:43:14 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 220 ms / 2,000 ms |
コード長 | 927 bytes |
コンパイル時間 | 1,848 ms |
コンパイル使用メモリ | 77,404 KB |
実行使用メモリ | 44,332 KB |
最終ジャッジ日時 | 2024-07-21 09:54:34 |
合計ジャッジ時間 | 7,458 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 23 |
ソースコード
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; } }