# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
442977 |
2021-07-09T12:35:12 Z |
zxcvbnm |
Kas (COCI17_kas) |
C++14 |
|
336 ms |
441276 KB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int maxS = 1e5 + 5;
const int INF = 1e9 + 5;
int dp[55][1005][1005];
vector<int> a;
int n;
int go(int k, int x, int y) {
if (dp[k][x][y] != -1) {
return dp[k][x][y];
}
int& ret = dp[k][x][y];
if (k == n) {
return ret = (x == y ? x : -INF);
}
return ret = max({go(k+1, x, y), go(k+1, x+a[k], y), go(k+1, x, y+a[k])});
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
memset(dp, -1, sizeof dp);
cin >> n;
a.resize(n);
for(int i = 0; i < n; i++) {
cin >> a[i];
}
int sum = accumulate(a.begin(), a.end(), 0);
int sol = go(0, 0, 0);
cout << (sol) + (sum - (sol*2));
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
104 ms |
217668 KB |
Output is correct |
2 |
Correct |
94 ms |
217600 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
95 ms |
217664 KB |
Output is correct |
2 |
Correct |
98 ms |
217596 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
95 ms |
217708 KB |
Output is correct |
2 |
Correct |
113 ms |
217680 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
97 ms |
217664 KB |
Output is correct |
2 |
Correct |
96 ms |
217656 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
97 ms |
217616 KB |
Output is correct |
2 |
Correct |
106 ms |
217684 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
146 ms |
217716 KB |
Output is correct |
2 |
Correct |
113 ms |
217596 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
158 ms |
217692 KB |
Output is correct |
2 |
Correct |
160 ms |
217712 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
336 ms |
441216 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
315 ms |
441276 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
303 ms |
441268 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |