結果
問題 | No.318 学学学学学 |
ユーザー |
|
提出日時 | 2023-02-15 17:59:49 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 159 ms / 2,000 ms |
コード長 | 679 bytes |
コンパイル時間 | 2,126 ms |
コンパイル使用メモリ | 223,136 KB |
実行使用メモリ | 24,088 KB |
最終ジャッジ日時 | 2024-06-22 17:30:25 |
合計ジャッジ時間 | 7,232 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 |
ソースコード
import std;int readInt() {int x;readf!" %d"(x);return x;}void main() {int n = readInt;auto a = new int[](n).map!(i => readInt);int[][int] hashMap;foreach(i; 0 .. n) {int x = readInt;hashMap[x] ~= i;}auto add = new int[][](n + 1);auto remove = new int[][](n + 1);foreach(key, value; hashMap) {int min = value[0];int max = value[$ - 1];add[min] ~= key;remove[max + 1] ~= key;}auto rbtree = new RedBlackTree!int;auto b = new int[](n);foreach(i; 0 .. n) {foreach(j; add[i])rbtree.insert(j);foreach(j; remove[i])rbtree.removeKey(j);b[i] = rbtree.back;}writeln(b.map!(i => i.to!string).join(" "));}