結果

問題 No.649 ここでちょっとQK!
ユーザー denderaKawazudenderaKawazu
提出日時 2018-02-10 00:07:25
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 1,429 bytes
コンパイル時間 2,643 ms
コンパイル使用メモリ 78,980 KB
実行使用メモリ 72,976 KB
最終ジャッジ日時 2024-04-17 13:10:49
合計ジャッジ時間 15,850 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 140 ms
47,316 KB
testcase_01 AC 141 ms
41,508 KB
testcase_02 AC 144 ms
41,800 KB
testcase_03 AC 1,636 ms
59,592 KB
testcase_04 AC 1,506 ms
72,280 KB
testcase_05 AC 1,484 ms
72,976 KB
testcase_06 AC 1,454 ms
71,924 KB
testcase_07 AC 146 ms
41,632 KB
testcase_08 AC 139 ms
41,376 KB
testcase_09 AC 131 ms
40,124 KB
testcase_10 AC 143 ms
41,788 KB
testcase_11 AC 146 ms
41,504 KB
testcase_12 TLE -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.LinkedList;
import java.util.Collections;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int q = in.nextInt();
            int k = in.nextInt();
            LinkedList<Long> num = new LinkedList<>();
            for (int i = 0; i < q; i++) {
                int qn = in.nextInt();
                if (qn == 1) {
                    num.add(in.nextLong());
                } else {
                    if (num.size() < k) {
                        out.println(-1);
                    } else {
                        Collections.sort(num);
                        long cn = num.get(k - 1);
                        out.println(cn);
                        num.remove(k - 1);
                    }
                }
                out.flush();
            }
        }

    }
}

0