# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
32275 | 2017-10-06T05:40:34 Z | cscandkswon | Kas (COCI17_kas) | C++14 | 203 ms | 197608 KB |
#include <cstdio> #include <cstdlib> const int MAXN = 503, INF=1e9; int N, A[MAXN], S, ans, D[MAXN][100005]; inline int max(int a, int b) { return (a > b) ? a : b; } int func(int a, int d) { if (d > S / 2) return -INF; if (a == N) { if (d == 0) return D[a][d]; return -INF; } if (D[a][d]) return D[a][d]; D[a][d] = max(func(a + 1, d), max(func(a + 1, d + A[a]) + A[a], func(a + 1, abs(d - A[a])))); return D[a][d]; } int main() { int i; scanf("%d", &N); for (i = 0; i < N; i++) scanf("%d", A + i), S+=A[i]; ans = func(0, 0); printf("%d", ans + (S - ans * 2)); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 197608 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 197608 KB | Output is correct |
2 | Incorrect | 0 ms | 197608 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 197608 KB | Output is correct |
2 | Incorrect | 0 ms | 197608 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 197608 KB | Output is correct |
2 | Correct | 0 ms | 197608 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 197608 KB | Output is correct |
2 | Correct | 0 ms | 197608 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 197608 KB | Output is correct |
2 | Correct | 0 ms | 197608 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 197608 KB | Output is correct |
2 | Correct | 0 ms | 197608 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 43 ms | 197608 KB | Output is correct |
2 | Correct | 19 ms | 197608 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 56 ms | 197608 KB | Output is correct |
2 | Correct | 126 ms | 197608 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 203 ms | 197608 KB | Output is correct |
2 | Correct | 193 ms | 197608 KB | Output is correct |