結果

問題 No.318 学学学学学
ユーザー te-shte-sh
提出日時 2017-06-28 17:44:22
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 113 ms / 2,000 ms
コード長 609 bytes
コンパイル時間 1,602 ms
コンパイル使用メモリ 153,332 KB
実行使用メモリ 12,112 KB
最終ジャッジ日時 2023-09-03 14:54:26
合計ジャッジ時間 5,757 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
4,380 KB
testcase_01 AC 17 ms
5,076 KB
testcase_02 AC 21 ms
6,368 KB
testcase_03 AC 14 ms
4,860 KB
testcase_04 AC 17 ms
6,100 KB
testcase_05 AC 93 ms
12,112 KB
testcase_06 AC 113 ms
10,708 KB
testcase_07 AC 105 ms
8,780 KB
testcase_08 AC 96 ms
7,812 KB
testcase_09 AC 89 ms
7,408 KB
testcase_10 AC 80 ms
6,744 KB
testcase_11 AC 92 ms
11,732 KB
testcase_12 AC 85 ms
9,360 KB
testcase_13 AC 82 ms
8,148 KB
testcase_14 AC 77 ms
7,876 KB
testcase_15 AC 74 ms
7,380 KB
testcase_16 AC 70 ms
6,760 KB
testcase_17 AC 92 ms
9,096 KB
testcase_18 AC 78 ms
8,912 KB
testcase_19 AC 94 ms
9,904 KB
testcase_20 AC 64 ms
6,308 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.algorithm, std.conv, std.range, std.stdio, std.string;
import std.container; // SList, DList, BinaryHeap

void 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;
}
0