Submission #1503322
Source Code Expand
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; void main() { auto s = readln.split.map!(to!int); auto N = s[0]; auto X = s[1].to!long; auto A = readln.split.map!(to!long).array; auto dp = new Tuple!(long, int)[](N); fill(dp, tuple(1L << 59, 1 << 29)); foreach (i; 0..N) { long cost = A[i]; foreach (jj; 0..N) { int j = (i + jj) % N; dp[j] = min(dp[j], tuple(cost, jj)); cost += X; } } long ans = dp.map!(d => d[1]).reduce!max * X; foreach (i; 0..N) { int j = (i - dp[i][1] + N) % N; ans += A[j]; } ans.writeln; }
Submission Info
Submission Time | |
---|---|
Task | B - Colorful Slimes |
User | nebukuro09 |
Language | D (LDC 0.17.0) |
Score | 0 |
Code Size | 802 Byte |
Status | WA |
Exec Time | 42 ms |
Memory | 2428 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 400 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_00.txt, 0_01.txt, 0_02.txt |
All | 0_00.txt, 0_01.txt, 0_02.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_00.txt | AC | 1 ms | 256 KB |
0_01.txt | AC | 1 ms | 256 KB |
0_02.txt | AC | 1 ms | 256 KB |
1_00.txt | AC | 41 ms | 380 KB |
1_01.txt | AC | 41 ms | 380 KB |
1_02.txt | AC | 42 ms | 2428 KB |
1_03.txt | AC | 42 ms | 380 KB |
1_04.txt | WA | 42 ms | 380 KB |
1_05.txt | AC | 42 ms | 508 KB |
1_06.txt | WA | 42 ms | 380 KB |
1_07.txt | AC | 42 ms | 380 KB |
1_08.txt | WA | 42 ms | 380 KB |
1_09.txt | AC | 42 ms | 380 KB |
1_10.txt | WA | 30 ms | 380 KB |
1_11.txt | WA | 40 ms | 380 KB |
1_12.txt | WA | 36 ms | 380 KB |
1_13.txt | WA | 25 ms | 380 KB |
1_14.txt | WA | 40 ms | 380 KB |
1_15.txt | WA | 31 ms | 380 KB |
1_16.txt | WA | 35 ms | 380 KB |
1_17.txt | WA | 40 ms | 380 KB |