結果

問題 No.318 学学学学学
ユーザー rabimearabimea
提出日時 2023-02-15 17:59:49
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 190 ms / 2,000 ms
コード長 679 bytes
コンパイル時間 2,115 ms
コンパイル使用メモリ 217,976 KB
実行使用メモリ 24,244 KB
最終ジャッジ日時 2023-09-04 19:51:02
合計ジャッジ時間 7,760 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
5,488 KB
testcase_01 AC 31 ms
7,540 KB
testcase_02 AC 38 ms
7,816 KB
testcase_03 AC 26 ms
6,820 KB
testcase_04 AC 33 ms
7,472 KB
testcase_05 AC 190 ms
24,244 KB
testcase_06 AC 177 ms
18,644 KB
testcase_07 AC 146 ms
14,756 KB
testcase_08 AC 129 ms
13,992 KB
testcase_09 AC 111 ms
13,656 KB
testcase_10 AC 100 ms
12,900 KB
testcase_11 AC 189 ms
23,692 KB
testcase_12 AC 143 ms
18,628 KB
testcase_13 AC 124 ms
14,808 KB
testcase_14 AC 112 ms
13,960 KB
testcase_15 AC 98 ms
12,960 KB
testcase_16 AC 86 ms
11,308 KB
testcase_17 AC 152 ms
18,948 KB
testcase_18 AC 134 ms
18,320 KB
testcase_19 AC 146 ms
17,896 KB
testcase_20 AC 75 ms
12,416 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 2 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;

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(" "));
}

0