結果
問題 | No.974 最後の日までに |
ユーザー | 👑 hos.lyric |
提出日時 | 2020-01-17 22:20:43 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 271 ms / 2,000 ms |
コード長 | 2,586 bytes |
コンパイル時間 | 1,020 ms |
コンパイル使用メモリ | 132,148 KB |
実行使用メモリ | 16,844 KB |
最終ジャッジ日時 | 2024-06-22 04:14:36 |
合計ジャッジ時間 | 11,728 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 252 ms
16,408 KB |
testcase_01 | AC | 249 ms
16,196 KB |
testcase_02 | AC | 244 ms
15,752 KB |
testcase_03 | AC | 244 ms
16,688 KB |
testcase_04 | AC | 243 ms
16,356 KB |
testcase_05 | AC | 247 ms
15,984 KB |
testcase_06 | AC | 245 ms
16,480 KB |
testcase_07 | AC | 249 ms
16,844 KB |
testcase_08 | AC | 244 ms
16,544 KB |
testcase_09 | AC | 246 ms
15,604 KB |
testcase_10 | AC | 247 ms
15,760 KB |
testcase_11 | AC | 247 ms
16,596 KB |
testcase_12 | AC | 250 ms
15,872 KB |
testcase_13 | AC | 245 ms
15,776 KB |
testcase_14 | AC | 248 ms
16,476 KB |
testcase_15 | AC | 250 ms
16,008 KB |
testcase_16 | AC | 254 ms
16,800 KB |
testcase_17 | AC | 267 ms
15,648 KB |
testcase_18 | AC | 265 ms
16,144 KB |
testcase_19 | AC | 259 ms
16,472 KB |
testcase_20 | AC | 260 ms
16,712 KB |
testcase_21 | AC | 255 ms
16,152 KB |
testcase_22 | AC | 255 ms
16,520 KB |
testcase_23 | AC | 265 ms
16,752 KB |
testcase_24 | AC | 258 ms
15,564 KB |
testcase_25 | AC | 1 ms
6,940 KB |
testcase_26 | AC | 2 ms
6,944 KB |
testcase_27 | AC | 187 ms
13,296 KB |
testcase_28 | AC | 251 ms
16,288 KB |
testcase_29 | AC | 1 ms
6,940 KB |
testcase_30 | AC | 262 ms
16,140 KB |
testcase_31 | AC | 1 ms
6,940 KB |
testcase_32 | AC | 2 ms
6,944 KB |
testcase_33 | AC | 155 ms
13,036 KB |
testcase_34 | AC | 258 ms
15,816 KB |
testcase_35 | AC | 1 ms
6,944 KB |
testcase_36 | AC | 1 ms
6,940 KB |
testcase_37 | AC | 271 ms
16,060 KB |
testcase_38 | AC | 1 ms
6,944 KB |
testcase_39 | AC | 1 ms
6,940 KB |
testcase_40 | AC | 146 ms
12,956 KB |
testcase_41 | AC | 188 ms
15,548 KB |
testcase_42 | AC | 260 ms
15,944 KB |
testcase_43 | AC | 256 ms
15,856 KB |
testcase_44 | AC | 194 ms
13,124 KB |
testcase_45 | AC | 157 ms
13,716 KB |
testcase_46 | AC | 2 ms
6,944 KB |
testcase_47 | AC | 1 ms
6,944 KB |
testcase_48 | AC | 1 ms
6,944 KB |
testcase_49 | AC | 1 ms
6,940 KB |
testcase_50 | AC | 1 ms
6,944 KB |
testcase_51 | AC | 1 ms
6,944 KB |
ソースコード
import std.conv, std.functional, std.range, std.stdio, std.string;import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, 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)); }enum INF = 10L^^18;void main() {try {for (; ; ) {const W = readInt();auto A = new long[W];auto B = new long[W];auto C = new long[W];foreach (i; 0 .. W) {A[i] = readLong();B[i] = readLong();C[i] = readLong();}long ans;foreach (m; W / 2 .. W / 2 + 2) {alias Entry = Tuple!(long, "x", long, "y");auto ess = new Entry[][2];void dfs(int s, int r, int i, long x, long y) {if (i == r) {ess[s] ~= Entry(x, y);return;}if (i + 1 <= r) {dfs(s, r, i + 1, x + A[i], y);}if (i + 2 <= r) {dfs(s, r, i + 2, x - C[i + 1], y + B[i + 1]);}}dfs(0, m, 0, 0, 0);dfs(1, W, m, 0, 0);ess[0].sort;ess[1].sort;debug {writeln("m = ", m);writeln("ess[0] = ", ess[0]);writeln("ess[1] = ", ess[1]);}const len0 = cast(int)(ess[0].length);const len1 = cast(int)(ess[1].length);long mx = -INF;for (int j = 0, k = len1; j < len0; ++j) {for (; k > 0 && ess[0][j].x + ess[1][k - 1].x >= 0; ) {chmax(mx, ess[1][--k].y);}chmax(ans, ess[0][j].y + mx);}}writeln(ans);}} catch (EOFException e) {}}