結果
問題 | No.2566 美しい整数列 |
ユーザー | InTheBloom |
提出日時 | 2023-12-02 16:56:24 |
言語 | D (dmd 2.106.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,489 bytes |
コンパイル時間 | 3,252 ms |
コンパイル使用メモリ | 164,064 KB |
実行使用メモリ | 63,272 KB |
最終ジャッジ日時 | 2023-12-02 16:56:36 |
合計ジャッジ時間 | 9,148 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,548 KB |
testcase_01 | AC | 2 ms
6,548 KB |
testcase_02 | AC | 2 ms
6,548 KB |
testcase_03 | AC | 1 ms
6,548 KB |
testcase_04 | AC | 310 ms
63,156 KB |
testcase_05 | AC | 338 ms
60,276 KB |
testcase_06 | AC | 155 ms
22,444 KB |
testcase_07 | AC | 169 ms
21,728 KB |
testcase_08 | AC | 157 ms
22,364 KB |
testcase_09 | AC | 162 ms
21,900 KB |
testcase_10 | AC | 161 ms
21,932 KB |
testcase_11 | AC | 200 ms
47,776 KB |
testcase_12 | AC | 213 ms
47,952 KB |
testcase_13 | AC | 206 ms
47,776 KB |
testcase_14 | AC | 207 ms
48,616 KB |
testcase_15 | AC | 185 ms
48,724 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | AC | 162 ms
50,712 KB |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | AC | 145 ms
53,660 KB |
testcase_23 | WA | - |
ソースコード
import std; void main () { int N, M; readln.read(N, M); int[] A = readln.split.to!(int[]); int[] B = readln.split.to!(int[]); int[] C = readln.split.to!(int[]); solve(N, M, A, B, C); } void solve (int N, int M, int[] A, int[] B, int[] C) { /* すでに関係が出来上がっている列はそのままor一挙変更であることがわかる。 つなぎ目をいい感じに選ぶ問題に帰着する -> 連想配列でいい感じに */ // 分割 int[] sp; sp ~= 0; foreach (i; 0..N-1) { if (A[i+1]-A[i] == B[i%M]) { continue; } sp ~= i+1; } sp ~= N; bool[int] spmp; foreach (s; sp) spmp[s] = true; long[] cum = new long[](N+1); // cum[i] := [0, i) cum[0] = 0; foreach (i; 1..N+1) { cum[i] = cum[i-1] + C[i-1]; } long[int] cost; foreach (i; 0..sp.length-1) { cost[sp[i]] = cum[sp[i+1]] - cum[sp[i]]; } // 初項が0であったときの美しい数列をトレス long[int] mp; int b = 0; foreach (i; 0..N) { if (i in spmp) { mp[A[i]-b] += cost[i]; } b += B[i%M]; } long ans = cum[N]; long sub = -long.max; foreach (key, val; mp) { sub = max(sub, val); } writeln(ans - sub); } void read (T...) (string S, ref T args) { auto buf = S.split; foreach (i, ref arg; args) { arg = buf[i].to!(typeof(arg)); } }