結果

問題 No.649 ここでちょっとQK!
ユーザー htensaihtensai
提出日時 2019-12-12 12:14:37
言語 Java21
(openjdk 21)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,194 bytes
コンパイル時間 7,263 ms
コンパイル使用メモリ 80,792 KB
実行使用メモリ 73,948 KB
最終ジャッジ日時 2023-09-07 03:32:36
合計ジャッジ時間 44,699 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
55,884 KB
testcase_01 AC 124 ms
56,492 KB
testcase_02 AC 126 ms
47,088 KB
testcase_03 AC 655 ms
52,132 KB
testcase_04 TLE -
testcase_05 AC 1,244 ms
71,740 KB
testcase_06 AC 1,161 ms
57,272 KB
testcase_07 AC 122 ms
56,140 KB
testcase_08 AC 122 ms
55,684 KB
testcase_09 AC 124 ms
55,632 KB
testcase_10 AC 126 ms
56,016 KB
testcase_11 AC 123 ms
55,936 KB
testcase_12 AC 1,307 ms
69,112 KB
testcase_13 AC 1,297 ms
55,400 KB
testcase_14 AC 1,261 ms
57,576 KB
testcase_15 AC 1,306 ms
69,532 KB
testcase_16 AC 1,265 ms
69,388 KB
testcase_17 AC 1,484 ms
59,828 KB
testcase_18 AC 1,452 ms
55,416 KB
testcase_19 AC 1,698 ms
58,024 KB
testcase_20 AC 1,796 ms
73,108 KB
testcase_21 AC 1,877 ms
71,980 KB
testcase_22 AC 1,849 ms
59,592 KB
testcase_23 AC 2,067 ms
61,748 KB
testcase_24 AC 2,232 ms
73,948 KB
testcase_25 AC 2,208 ms
60,976 KB
testcase_26 AC 2,495 ms
61,220 KB
testcase_27 AC 203 ms
58,712 KB
testcase_28 AC 196 ms
56,928 KB
testcase_29 AC 200 ms
59,320 KB
testcase_30 AC 1,200 ms
69,352 KB
testcase_31 AC 1,310 ms
70,744 KB
testcase_32 AC 126 ms
55,908 KB
testcase_33 AC 123 ms
55,476 KB
testcase_34 AC 124 ms
55,764 KB
testcase_35 AC 124 ms
55,732 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int q = sc.nextInt();
        int k = sc.nextInt();
        ArrayList<Long> list = new ArrayList<>();
        list.add(0L);
        list.add(Long.MAX_VALUE);
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < q; i++) {
            int x = sc.nextInt();
            if (x == 1) {
                long y = sc.nextLong();
                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);
    }
}
0