結果
問題 | No.649 ここでちょっとQK! |
ユーザー | htensai |
提出日時 | 2019-12-12 12:18:57 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 2,492 ms / 3,000 ms |
コード長 | 1,388 bytes |
コンパイル時間 | 2,485 ms |
コンパイル使用メモリ | 76,044 KB |
実行使用メモリ | 65,260 KB |
最終ジャッジ日時 | 2023-09-07 03:38:24 |
合計ジャッジ時間 | 26,435 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 46 ms
47,032 KB |
testcase_01 | AC | 45 ms
49,312 KB |
testcase_02 | AC | 45 ms
49,248 KB |
testcase_03 | AC | 206 ms
56,652 KB |
testcase_04 | AC | 2,492 ms
63,580 KB |
testcase_05 | AC | 364 ms
65,064 KB |
testcase_06 | AC | 352 ms
65,260 KB |
testcase_07 | AC | 46 ms
49,188 KB |
testcase_08 | AC | 45 ms
49,184 KB |
testcase_09 | AC | 45 ms
49,240 KB |
testcase_10 | AC | 46 ms
49,180 KB |
testcase_11 | AC | 45 ms
49,368 KB |
testcase_12 | AC | 659 ms
62,312 KB |
testcase_13 | AC | 659 ms
61,792 KB |
testcase_14 | AC | 657 ms
62,056 KB |
testcase_15 | AC | 634 ms
62,116 KB |
testcase_16 | AC | 647 ms
60,416 KB |
testcase_17 | AC | 751 ms
62,408 KB |
testcase_18 | AC | 769 ms
62,488 KB |
testcase_19 | AC | 827 ms
62,200 KB |
testcase_20 | AC | 911 ms
62,432 KB |
testcase_21 | AC | 1,040 ms
62,352 KB |
testcase_22 | AC | 1,071 ms
62,276 KB |
testcase_23 | AC | 1,191 ms
64,568 KB |
testcase_24 | AC | 1,255 ms
64,248 KB |
testcase_25 | AC | 1,359 ms
64,380 KB |
testcase_26 | AC | 1,466 ms
64,592 KB |
testcase_27 | AC | 59 ms
50,144 KB |
testcase_28 | AC | 60 ms
51,064 KB |
testcase_29 | AC | 59 ms
51,060 KB |
testcase_30 | AC | 601 ms
63,384 KB |
testcase_31 | AC | 585 ms
61,924 KB |
testcase_32 | AC | 45 ms
47,360 KB |
testcase_33 | AC | 45 ms
49,512 KB |
testcase_34 | AC | 44 ms
49,224 KB |
testcase_35 | AC | 44 ms
49,436 KB |
ソースコード
import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] first = br.readLine().split(" ", 2); int q = Integer.parseInt(first[0]); int k = Integer.parseInt(first[1]); ArrayList<Long> list = new ArrayList<>(); list.add(0L); list.add(Long.MAX_VALUE); StringBuilder sb = new StringBuilder(); for (int i = 0; i < q; i++) { String line = br.readLine(); if (line.charAt(0) == '1') { long y = Long.parseLong(line.substring(2, line.length())); int left = 0; int right = list.size() - 1; while (right - left > 1) { int m = (left + right) / 2; if (list.get(m) <= y) { left = m; } else { right = m; } } list.add(right, y); } else { long ans; if (list.size() < k + 2) { ans = -1; } else { ans = list.remove(k); } sb.append(ans).append("\n"); } } System.out.print(sb); } }