結果
| 問題 |
No.610 区間賞(Section Award)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-12-10 00:23:28 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
AC
|
| 実行時間 | 94 ms / 2,000 ms |
| コード長 | 1,049 bytes |
| コンパイル時間 | 1,618 ms |
| コンパイル使用メモリ | 157,492 KB |
| 実行使用メモリ | 12,108 KB |
| 最終ジャッジ日時 | 2024-06-12 22:57:50 |
| 合計ジャッジ時間 | 5,548 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 50 |
ソースコード
import std.stdio, std.string, std.conv, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;
void main() {
int n;
scan(n);
auto a = readln.split.to!(int[]);
auto b = readln.split.to!(int[]);
auto ar = new int[](n + 1);
foreach (i ; 0 .. n) {
ar[a[i]] = i;
}
auto set = redBlackTree!(int)();
auto aw = new bool[](n + 1);
foreach (i ; 0 .. n) {
set.insert(ar[b[i]]);
if (set.upperBound(ar[b[i]]).empty) {
aw[b[i]] = true;
}
}
foreach (i ; 1 .. n + 1) {
if (aw[i]) writeln(i);
}
}
void scan(T...)(ref T args) {
string[] line = readln.split;
foreach (ref arg; args) {
arg = line.front.to!(typeof(arg));
line.popFront();
}
assert(line.empty);
}
void fillAll(R, T)(ref R arr, T value) {
static if (is(typeof(arr[] = value))) {
arr[] = value;
}
else {
foreach (ref e; arr) {
fillAll(e, value);
}
}
}