結果
問題 | No.808 Kaiten Sushi? |
ユーザー | nebukuro09 |
提出日時 | 2019-03-22 22:31:36 |
言語 | D (dmd 2.107.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,150 bytes |
コンパイル時間 | 1,888 ms |
コンパイル使用メモリ | 198,672 KB |
実行使用メモリ | 23,996 KB |
最終ジャッジ日時 | 2023-09-03 23:52:46 |
合計ジャッジ時間 | 9,889 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | AC | 1 ms
4,380 KB |
testcase_07 | AC | 3 ms
4,380 KB |
testcase_08 | AC | 3 ms
4,376 KB |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | AC | 2 ms
4,376 KB |
testcase_18 | AC | 2 ms
4,376 KB |
testcase_19 | AC | 1 ms
4,380 KB |
testcase_20 | AC | 2 ms
4,376 KB |
testcase_21 | AC | 1 ms
4,376 KB |
testcase_22 | AC | 2 ms
4,376 KB |
testcase_23 | AC | 74 ms
15,664 KB |
testcase_24 | AC | 57 ms
10,872 KB |
testcase_25 | AC | 68 ms
14,764 KB |
testcase_26 | AC | 66 ms
13,596 KB |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | AC | 1 ms
4,380 KB |
testcase_38 | AC | 1 ms
4,376 KB |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | WA | - |
testcase_43 | WA | - |
testcase_44 | WA | - |
testcase_45 | WA | - |
testcase_46 | WA | - |
testcase_47 | WA | - |
testcase_48 | WA | - |
testcase_49 | WA | - |
testcase_50 | WA | - |
testcase_51 | WA | - |
testcase_52 | AC | 65 ms
11,604 KB |
testcase_53 | AC | 89 ms
11,108 KB |
testcase_54 | AC | 2 ms
4,376 KB |
testcase_55 | AC | 1 ms
4,380 KB |
testcase_56 | AC | 1 ms
4,380 KB |
testcase_57 | AC | 28 ms
6,468 KB |
testcase_58 | AC | 47 ms
8,000 KB |
ソースコード
import std.stdio, std.array, std.string, std.conv, std.algorithm; import std.typecons, std.range, std.random, std.math, std.container; import std.numeric, std.bigint, core.bitop, core.stdc.string; immutable long MOD = 10^^9 + 7; void main() { auto s = readln.split; auto N = s[0].to!int; auto L = s[1].to!long; auto A = readln.split.map!(to!long).array; auto B = readln.split.map!(to!long).array; Tuple!(int, int, int, long)[] C; for (int i = 0, j = 0; i < N || j < N; ) { if (j >= N || (i < N && A[i] < B[j])) { if (!C.empty && C.back[2] == 0) { C.back[1] = i; C.back[3] = A[i]; } else { C ~= tuple(i, i, 0, A[i]); } ++i; } else { if (!C.empty && C.back[2] == 1) { C.back[1] = j; C.back[3] = B[j]; } else { C ~= tuple(j, j, 1, B[j]); } ++j; } } if (C.back[2] == C.front[2]) { auto t = C.back; C.popBack; C.front[0] = t[0]; } auto rbt = new RedBlackTree!(Tuple!(int, int, int, long), "a[3] < b[3]"); rbt.insert(C); long ans = 0; long pos = 0; int turn = 0; foreach (_; 0..2*N) { auto ub = rbt.upperBound(tuple(0, 0, 0, pos)); if (ub.empty) { ub = rbt.upperBound(tuple(0, 0, 0, 0L)); } else if (ub.front == rbt.back) { if (turn != ub.front[2]) ub = rbt.upperBound(tuple(0, 0, 0, 0L)); } if (turn != ub.front[2]) { ub.popFront; if (ub.empty) ub = rbt.upperBound(tuple(0, 0, 0, 0L)); } auto tar = ub.front; long next = tar[3]; if (pos < next) ans += next - pos; else ans += L - pos + next; pos = next; rbt.removeKey(tar); if (tar[0] != tar[1]) { tar[1] -= 1; if (tar[1] < 0) tar[1] = N - 1; if (tar[2] == 0) tar[3] = A[tar[1]]; else tar[3] = B[tar[1]]; rbt.insert(tar); } turn ^= 1; } ans.writeln; }