結果
問題 | No.808 Kaiten Sushi? |
ユーザー | 👑 hos.lyric |
提出日時 | 2019-03-24 15:21:33 |
言語 | D (dmd 2.107.1) |
結果 |
AC
|
実行時間 | 179 ms / 2,000 ms |
コード長 | 2,617 bytes |
コンパイル時間 | 1,457 ms |
コンパイル使用メモリ | 159,436 KB |
実行使用メモリ | 23,496 KB |
最終ジャッジ日時 | 2023-09-03 23:53:55 |
合計ジャッジ時間 | 6,710 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,380 KB |
testcase_01 | AC | 2 ms
4,380 KB |
testcase_02 | AC | 2 ms
4,376 KB |
testcase_03 | AC | 1 ms
4,376 KB |
testcase_04 | AC | 1 ms
4,380 KB |
testcase_05 | AC | 2 ms
4,376 KB |
testcase_06 | AC | 1 ms
4,380 KB |
testcase_07 | AC | 2 ms
4,380 KB |
testcase_08 | AC | 3 ms
4,380 KB |
testcase_09 | AC | 5 ms
4,376 KB |
testcase_10 | AC | 3 ms
4,376 KB |
testcase_11 | AC | 3 ms
4,380 KB |
testcase_12 | AC | 4 ms
4,380 KB |
testcase_13 | AC | 3 ms
4,376 KB |
testcase_14 | AC | 2 ms
4,376 KB |
testcase_15 | AC | 4 ms
4,376 KB |
testcase_16 | AC | 4 ms
4,376 KB |
testcase_17 | AC | 2 ms
4,380 KB |
testcase_18 | AC | 2 ms
4,376 KB |
testcase_19 | AC | 2 ms
4,376 KB |
testcase_20 | AC | 2 ms
4,376 KB |
testcase_21 | AC | 2 ms
4,380 KB |
testcase_22 | AC | 2 ms
4,380 KB |
testcase_23 | AC | 41 ms
10,676 KB |
testcase_24 | AC | 33 ms
9,780 KB |
testcase_25 | AC | 38 ms
10,176 KB |
testcase_26 | AC | 36 ms
9,660 KB |
testcase_27 | AC | 123 ms
18,588 KB |
testcase_28 | AC | 36 ms
9,636 KB |
testcase_29 | AC | 117 ms
16,472 KB |
testcase_30 | AC | 72 ms
11,788 KB |
testcase_31 | AC | 131 ms
17,660 KB |
testcase_32 | AC | 145 ms
20,060 KB |
testcase_33 | AC | 70 ms
12,312 KB |
testcase_34 | AC | 81 ms
12,816 KB |
testcase_35 | AC | 99 ms
18,192 KB |
testcase_36 | AC | 70 ms
13,036 KB |
testcase_37 | AC | 1 ms
4,376 KB |
testcase_38 | AC | 1 ms
4,380 KB |
testcase_39 | AC | 161 ms
19,976 KB |
testcase_40 | AC | 35 ms
7,628 KB |
testcase_41 | AC | 37 ms
8,192 KB |
testcase_42 | AC | 122 ms
16,296 KB |
testcase_43 | AC | 49 ms
9,604 KB |
testcase_44 | AC | 93 ms
13,724 KB |
testcase_45 | AC | 50 ms
10,108 KB |
testcase_46 | AC | 27 ms
6,188 KB |
testcase_47 | AC | 178 ms
22,876 KB |
testcase_48 | AC | 179 ms
23,400 KB |
testcase_49 | AC | 172 ms
23,496 KB |
testcase_50 | AC | 171 ms
23,224 KB |
testcase_51 | AC | 173 ms
23,004 KB |
testcase_52 | AC | 78 ms
16,668 KB |
testcase_53 | AC | 113 ms
20,328 KB |
testcase_54 | AC | 2 ms
4,376 KB |
testcase_55 | AC | 1 ms
4,376 KB |
testcase_56 | AC | 2 ms
4,376 KB |
testcase_57 | AC | 39 ms
10,016 KB |
testcase_58 | AC | 62 ms
12,460 KB |
ソースコード
/* +-------------+ | | o---o x o x o x x | | | | | | +-+ +-+ +---+ */ import std.conv, std.functional, std.stdio, std.string; import std.algorithm, std.array, std.bigint, std.container, std.math, std.numeric, std.range, std.regex, std.typecons; import core.bitop; class EOFException : Throwable { this() { super("EOF"); } } string[] tokens; string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; } int readInt() { return readToken.to!int; } long readLong() { return readToken.to!long; } real readReal() { return readToken.to!real; } bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } } bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } } int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; } int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); } int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); } int N; long L; long[] X, Y; void main() { try { for (; ; ) { N = readInt(); L = readLong(); X = new long[N]; Y = new long[N]; foreach (i; 0 .. N) { X[i] = readLong(); } foreach (i; 0 .. N) { Y[i] = readLong(); } auto xs = X.redBlackTree!true; auto ys = Y.redBlackTree!true; debug { writeln("xs = ", xs); writeln("ys = ", ys); } long ans = 0, cur = 0; foreach (i; 0 .. N) { auto rx = xs.upperBound(cur); if (rx.empty) { rx = xs[]; } const x = rx.front; xs.removeKey(x); auto ry = ys.upperBound(x); if (ry.empty) { ry = ys[]; } long y = ry.front; if (!rx.empty) { auto rz = xs.upperBound(y); if (rz.empty) { rz = xs[]; } const z = rz.front; auto rw = ys.lowerBound(z); if (rw.empty) { rw = ys[]; } const w = rw.back; y = w; } ys.removeKey(y); debug { writefln("o %s, x %s", x, y); } if (cur > x) { ans += L; } if (x > y) { ans += L; } cur = y; } ans += cur; writeln(ans); } } catch (EOFException e) { } }