# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
22548 | 2017-04-30T05:28:32 Z | 2000/4000(#946, 0xrgb) | Unifying Values (KRIII5_UV) | C++14 | 500 ms | 1992 KB |
#include <cstdio> #include <map> using namespace std; const int MAXN = 10004; const int P = 1000 * 1000 * 1000 + 7; typedef long long lli; int N; lli S[MAXN]; lli D[MAXN]; map<lli,int> dp; int main() { scanf("%d", &N); for (int i = 1; i <= N; ++i) { scanf("%lld", &D[i]); S[i] += S[i - 1] + D[i]; } int cnt = 0; for (int i = 1; i < N; ++i) { // 1 ~ i const lli st = S[i] - S[0]; if (st != 0 && S[N] % st != 0) continue; dp.clear(); dp[S[N]] = 1; for (int j = N - 1; j > i; --j) { auto it = dp.find(S[j] + st); if (it == dp.end()) continue; else dp[S[j]] = (dp[S[j]] + it->second) % P; } cnt = (cnt + dp[S[i] + st]) % P; } printf("%d\n", cnt); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 1332 KB | Output is correct |
2 | Correct | 0 ms | 1332 KB | Output is correct |
3 | Correct | 0 ms | 1332 KB | Output is correct |
4 | Correct | 9 ms | 1992 KB | Output is correct |
5 | Correct | 6 ms | 1992 KB | Output is correct |
6 | Correct | 499 ms | 1332 KB | Output is correct |
7 | Correct | 13 ms | 1464 KB | Output is correct |
8 | Correct | 6 ms | 1464 KB | Output is correct |
9 | Correct | 13 ms | 1464 KB | Output is correct |
10 | Correct | 43 ms | 1332 KB | Output is correct |
11 | Correct | 6 ms | 1332 KB | Output is correct |
12 | Correct | 49 ms | 1332 KB | Output is correct |
13 | Correct | 13 ms | 1464 KB | Output is correct |
14 | Correct | 19 ms | 1464 KB | Output is correct |
15 | Correct | 6 ms | 1464 KB | Output is correct |
16 | Correct | 9 ms | 1464 KB | Output is correct |
17 | Correct | 6 ms | 1464 KB | Output is correct |
18 | Correct | 56 ms | 1332 KB | Output is correct |
19 | Correct | 206 ms | 1332 KB | Output is correct |
20 | Correct | 323 ms | 1332 KB | Output is correct |
21 | Correct | 353 ms | 1332 KB | Output is correct |
22 | Correct | 456 ms | 1332 KB | Output is correct |
23 | Correct | 493 ms | 1332 KB | Output is correct |
24 | Correct | 459 ms | 1332 KB | Output is correct |
25 | Correct | 473 ms | 1332 KB | Output is correct |
26 | Correct | 409 ms | 1332 KB | Output is correct |
27 | Correct | 76 ms | 1332 KB | Output is correct |
28 | Correct | 193 ms | 1332 KB | Output is correct |
29 | Correct | 123 ms | 1332 KB | Output is correct |
30 | Correct | 16 ms | 1332 KB | Output is correct |
31 | Correct | 9 ms | 1332 KB | Output is correct |
32 | Correct | 9 ms | 1332 KB | Output is correct |
33 | Correct | 196 ms | 1332 KB | Output is correct |
34 | Correct | 39 ms | 1332 KB | Output is correct |
35 | Correct | 39 ms | 1332 KB | Output is correct |
36 | Correct | 33 ms | 1332 KB | Output is correct |
37 | Correct | 86 ms | 1332 KB | Output is correct |
38 | Correct | 39 ms | 1332 KB | Output is correct |
39 | Correct | 103 ms | 1332 KB | Output is correct |
40 | Correct | 16 ms | 1332 KB | Output is correct |
41 | Correct | 19 ms | 1464 KB | Output is correct |
42 | Correct | 16 ms | 1332 KB | Output is correct |
43 | Correct | 29 ms | 1464 KB | Output is correct |
44 | Correct | 19 ms | 1332 KB | Output is correct |
45 | Correct | 39 ms | 1332 KB | Output is correct |
46 | Correct | 19 ms | 1332 KB | Output is correct |
47 | Correct | 13 ms | 1464 KB | Output is correct |
48 | Correct | 13 ms | 1464 KB | Output is correct |
49 | Correct | 16 ms | 1464 KB | Output is correct |
50 | Correct | 6 ms | 1464 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 16 ms | 1464 KB | Output is correct |
2 | Correct | 13 ms | 1464 KB | Output is correct |
3 | Correct | 3 ms | 1464 KB | Output is correct |
4 | Correct | 59 ms | 1332 KB | Output is correct |
5 | Correct | 36 ms | 1332 KB | Output is correct |
6 | Correct | 33 ms | 1332 KB | Output is correct |
7 | Correct | 26 ms | 1464 KB | Output is correct |
8 | Correct | 9 ms | 1464 KB | Output is correct |
9 | Correct | 9 ms | 1332 KB | Output is correct |
10 | Correct | 0 ms | 1332 KB | Output is correct |
11 | Correct | 0 ms | 1332 KB | Output is correct |
12 | Correct | 0 ms | 1332 KB | Output is correct |
13 | Correct | 0 ms | 1332 KB | Output is correct |
14 | Correct | 0 ms | 1332 KB | Output is correct |
15 | Correct | 0 ms | 1332 KB | Output is correct |
16 | Correct | 0 ms | 1332 KB | Output is correct |
17 | Correct | 9 ms | 1992 KB | Output is correct |
18 | Correct | 9 ms | 1992 KB | Output is correct |
19 | Correct | 439 ms | 1332 KB | Output is correct |
20 | Correct | 289 ms | 1332 KB | Output is correct |
21 | Correct | 293 ms | 1332 KB | Output is correct |
22 | Correct | 296 ms | 1332 KB | Output is correct |
23 | Correct | 409 ms | 1332 KB | Output is correct |
24 | Correct | 486 ms | 1332 KB | Output is correct |
25 | Correct | 459 ms | 1332 KB | Output is correct |
26 | Execution timed out | 500 ms | 1332 KB | Execution timed out |
27 | Halted | 0 ms | 0 KB | - |