結果
問題 | No.318 学学学学学 |
ユーザー |
|
提出日時 | 2017-06-28 17:44:22 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 106 ms / 2,000 ms |
コード長 | 609 bytes |
コンパイル時間 | 1,693 ms |
コンパイル使用メモリ | 155,680 KB |
実行使用メモリ | 11,628 KB |
最終ジャッジ日時 | 2024-06-12 20:37:55 |
合計ジャッジ時間 | 5,359 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 |
ソースコード
import std.algorithm, std.conv, std.range, std.stdio, std.string;import std.container; // SList, DList, BinaryHeapvoid main(){auto n = readln.chomp.to!size_t;auto a = readln.split.to!(int[]);auto r = new int[](n);size_t[int] hash;foreach (i, ai; a) {if (ai in hash) r[hash[ai]] = 0;r[i] = ai;hash[ai] = i;}auto b = new int[](n);auto rbt = redBlackTree!("a > b", int)();foreach (i, ai; a) {rbt.insert(ai);b[i] = rbt.front;if (r[i] > 0) rbt.removeKey(r[i]);}foreach (i, bi; b) {write(bi);if (i < n-1) write(" ");}writeln;}