結果
問題 | No.1597 Matrix Sort |
ユーザー | lavox |
提出日時 | 2021-07-09 22:33:44 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,268 bytes |
コンパイル時間 | 2,117 ms |
コンパイル使用メモリ | 74,304 KB |
実行使用メモリ | 72,236 KB |
最終ジャッジ日時 | 2023-09-14 09:53:30 |
合計ジャッジ時間 | 31,188 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 120 ms
55,760 KB |
testcase_01 | AC | 126 ms
56,264 KB |
testcase_02 | AC | 124 ms
55,584 KB |
testcase_03 | AC | 1,283 ms
68,652 KB |
testcase_04 | AC | 1,287 ms
66,088 KB |
testcase_05 | AC | 1,431 ms
70,632 KB |
testcase_06 | AC | 1,407 ms
70,524 KB |
testcase_07 | WA | - |
testcase_08 | AC | 1,224 ms
70,664 KB |
testcase_09 | AC | 1,220 ms
72,236 KB |
testcase_10 | AC | 755 ms
67,512 KB |
testcase_11 | AC | 760 ms
67,872 KB |
testcase_12 | AC | 1,042 ms
65,564 KB |
testcase_13 | AC | 1,369 ms
69,904 KB |
testcase_14 | AC | 1,376 ms
70,868 KB |
testcase_15 | AC | 913 ms
67,808 KB |
testcase_16 | AC | 1,068 ms
68,224 KB |
testcase_17 | AC | 1,339 ms
70,880 KB |
testcase_18 | AC | 1,303 ms
65,924 KB |
testcase_19 | AC | 1,326 ms
68,264 KB |
testcase_20 | AC | 1,304 ms
68,244 KB |
testcase_21 | AC | 1,350 ms
70,444 KB |
testcase_22 | AC | 1,025 ms
64,220 KB |
testcase_23 | AC | 963 ms
68,216 KB |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | AC | 119 ms
55,624 KB |
testcase_27 | AC | 124 ms
56,040 KB |
testcase_28 | AC | 120 ms
55,864 KB |
testcase_29 | AC | 124 ms
56,324 KB |
ソースコード
import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = Integer.parseInt(sc.next()); long K = Long.parseLong(sc.next()); int P = Integer.parseInt(sc.next()); int[] A = new int[N]; for ( int i = 0 ; i < N ; i++ ) { A[i] = Integer.parseInt(sc.next()); } int[] B = new int[N]; for ( int i = 0 ; i < N ; i++ ) { B[i] = Integer.parseInt(sc.next()); } sc.close(); Arrays.sort(B); int min = 0; int max = P - 1; while ( max - min > 1 ) { int mid = (min + max) / 2; if ( count(A, B, mid, P) < K ) { min = mid; } else { max = mid; } } System.out.println(min); } static long count(int[] A, int[] B, int x, int P) { long cnt = 0; for ( int a : A ) { // 0 == x, P == x + P cnt += count(B, x - a); cnt += count(B, x + P - a) - count(B, P - a); } return cnt; } static long count(int[] B, int x) { if ( B[0] >= x ) { return 0; } else if ( B[B.length - 1] < x ) { return B.length; } int min = 0; int max = B.length - 1; while ( max - min > 1 ) { int mid = (min + max) / 2; if ( B[mid] < x ) { min = mid; } else { max = mid; } } return min + 1; } }