結果
問題 | No.649 ここでちょっとQK! |
ユーザー | バカらっく |
提出日時 | 2018-02-13 15:37:46 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 693 ms / 3,000 ms |
コード長 | 1,988 bytes |
コンパイル時間 | 2,927 ms |
コンパイル使用メモリ | 81,268 KB |
実行使用メモリ | 59,288 KB |
最終ジャッジ日時 | 2024-05-07 00:40:48 |
合計ジャッジ時間 | 17,645 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 55 ms
37,296 KB |
testcase_01 | AC | 50 ms
36,768 KB |
testcase_02 | AC | 57 ms
36,872 KB |
testcase_03 | AC | 262 ms
47,884 KB |
testcase_04 | AC | 693 ms
59,288 KB |
testcase_05 | AC | 579 ms
55,496 KB |
testcase_06 | AC | 549 ms
55,496 KB |
testcase_07 | AC | 56 ms
37,508 KB |
testcase_08 | AC | 60 ms
37,460 KB |
testcase_09 | AC | 58 ms
37,024 KB |
testcase_10 | AC | 58 ms
37,436 KB |
testcase_11 | AC | 57 ms
37,412 KB |
testcase_12 | AC | 404 ms
52,748 KB |
testcase_13 | AC | 462 ms
52,844 KB |
testcase_14 | AC | 401 ms
52,844 KB |
testcase_15 | AC | 517 ms
54,824 KB |
testcase_16 | AC | 418 ms
52,276 KB |
testcase_17 | AC | 528 ms
54,320 KB |
testcase_18 | AC | 594 ms
54,080 KB |
testcase_19 | AC | 607 ms
54,548 KB |
testcase_20 | AC | 591 ms
54,760 KB |
testcase_21 | AC | 641 ms
55,708 KB |
testcase_22 | AC | 656 ms
56,704 KB |
testcase_23 | AC | 638 ms
56,360 KB |
testcase_24 | AC | 650 ms
56,108 KB |
testcase_25 | AC | 677 ms
57,460 KB |
testcase_26 | AC | 670 ms
57,704 KB |
testcase_27 | AC | 86 ms
38,780 KB |
testcase_28 | AC | 94 ms
38,212 KB |
testcase_29 | AC | 101 ms
38,564 KB |
testcase_30 | AC | 388 ms
51,792 KB |
testcase_31 | AC | 487 ms
53,496 KB |
testcase_32 | AC | 57 ms
37,436 KB |
testcase_33 | AC | 55 ms
37,468 KB |
testcase_34 | AC | 54 ms
37,396 KB |
testcase_35 | AC | 49 ms
37,184 KB |
ソースコード
import java.io.BufferedReader; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.PriorityQueue; public class Main { public BufferedReader br; /** * メイン処理 * @throws IOException */ public void Proc() throws IOException { int[] inpt = getIntArray(); int q = inpt[0]; int k = inpt[1]; PriorityQueue<Long> q1 = new PriorityQueue<>(); PriorityQueue<Long> q2 = new PriorityQueue<>(); StringBuilder ans = new StringBuilder(); for(int i=0; i<q; i++) { long[] tm = getLongArray(); if(tm[0]==1) { if(q1.size()<k-1) { q1.add(tm[1]*-1); } else if(q2.size()==0||q2.peek()>tm[1]) { q1.add(tm[1]*-1); q2.add(q1.poll()*-1); } else { q2.add(tm[1]); } } else { if(q2.size()<=0){ ans.append("-1\n"); } else { ans.append(q2.poll()+"\n"); } } } System.out.print(ans.toString()); } private long[] getLongArray() throws IOException { String[] inpt = br.readLine().split(" "); List<Long> lst = new ArrayList<>(); for(String tmp:inpt) { lst.add(Long.parseLong(tmp)); } long[] ret = new long[lst.size()]; for(int i=0; i<ret.length;i++) { ret[i] = lst.get(i); } return ret; } private int[] getIntArray() throws IOException { String[] inpt = br.readLine().split(" "); List<Integer> lst = new ArrayList<>(); for(String tmp:inpt) { lst.add(Integer.parseInt(tmp)); } int[] ret = new int[lst.size()]; for(int i=0; i<ret.length;i++) { ret[i] = lst.get(i); } return ret; } public static void main(String[] args) { Main mn = new Main(); mn.br = new java.io.BufferedReader(new java.io.InputStreamReader(System.in)); try { mn.Proc(); } catch (IOException e) { // TODO 自動生成された catch ブロック e.printStackTrace(); } finally { try { mn.br.close(); } catch (IOException e) { // TODO 自動生成された catch ブロック e.printStackTrace(); } } } }