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