結果
問題 | No.649 ここでちょっとQK! |
ユーザー | te-sh |
提出日時 | 2018-04-19 15:36:22 |
言語 | D (dmd 2.106.1) |
結果 |
AC
|
実行時間 | 229 ms / 3,000 ms |
コード長 | 1,071 bytes |
コンパイル時間 | 1,386 ms |
コンパイル使用メモリ | 154,024 KB |
実行使用メモリ | 17,988 KB |
最終ジャッジ日時 | 2023-09-03 19:49:21 |
合計ジャッジ時間 | 6,704 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,380 KB |
testcase_01 | AC | 2 ms
4,376 KB |
testcase_02 | AC | 1 ms
4,376 KB |
testcase_03 | AC | 98 ms
4,376 KB |
testcase_04 | AC | 190 ms
17,988 KB |
testcase_05 | AC | 148 ms
15,320 KB |
testcase_06 | AC | 181 ms
16,516 KB |
testcase_07 | AC | 1 ms
4,376 KB |
testcase_08 | AC | 2 ms
4,380 KB |
testcase_09 | AC | 1 ms
4,376 KB |
testcase_10 | AC | 2 ms
4,380 KB |
testcase_11 | AC | 1 ms
4,380 KB |
testcase_12 | AC | 93 ms
7,936 KB |
testcase_13 | AC | 92 ms
7,908 KB |
testcase_14 | AC | 88 ms
7,900 KB |
testcase_15 | AC | 95 ms
8,412 KB |
testcase_16 | AC | 90 ms
8,696 KB |
testcase_17 | AC | 107 ms
11,244 KB |
testcase_18 | AC | 117 ms
11,792 KB |
testcase_19 | AC | 128 ms
12,568 KB |
testcase_20 | AC | 143 ms
13,848 KB |
testcase_21 | AC | 151 ms
14,072 KB |
testcase_22 | AC | 162 ms
15,104 KB |
testcase_23 | AC | 202 ms
15,416 KB |
testcase_24 | AC | 201 ms
15,332 KB |
testcase_25 | AC | 229 ms
15,336 KB |
testcase_26 | AC | 220 ms
15,412 KB |
testcase_27 | AC | 2 ms
4,376 KB |
testcase_28 | AC | 2 ms
4,376 KB |
testcase_29 | AC | 2 ms
4,376 KB |
testcase_30 | AC | 79 ms
7,904 KB |
testcase_31 | AC | 83 ms
8,376 KB |
testcase_32 | AC | 1 ms
4,380 KB |
testcase_33 | AC | 1 ms
4,376 KB |
testcase_34 | AC | 1 ms
4,380 KB |
testcase_35 | AC | 1 ms
4,380 KB |
ソースコード
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string; auto rdsp(){return readln.splitter;} void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;} void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);} void main() { int q, k; readV(q, k); auto rb1 = redBlackTree!("a>b", true, long)(), rb2 = redBlackTree!("a<b", true, long)(); foreach (_; 0..q) { auto rd = rdsp; string typ; pick(rd, typ); switch (typ) { case "1": long v; pick(rd, v); if (rb1.length < k) { rb1.insert(v); } else if (rb1.front < v) { rb2.insert(v); } else { auto u = rb1.front; rb1.removeFront; rb1.insert(v); rb2.insert(u); } break; case "2": if (rb1.length < k) { writeln(-1); } else { writeln(rb1.front); rb1.removeFront; if (!rb2.empty) { auto u = rb2.front; rb2.removeFront; rb1.insert(u); } } break; default: assert(0); } } }