# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
244863 |
2020-07-05T07:47:36 Z |
VEGAnn |
Kas (COCI17_kas) |
C++14 |
|
264 ms |
1952 KB |
#include <bits/stdc++.h>
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
using namespace std;
const int N = 510;
const int M = 100100;
int f[2][2 * M], tp = 0, sum = 0, n;
void upd(int &x, int y){
x = max(x, y);
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef _LOCAL
freopen("in.txt","r",stdin);
#endif // _LOCAL
cin >> n;
fill(f[0], f[0] + 2 * M, -1);
f[0][M] = 0;
for (int it = 0; it < n; it++){
int x; cin >> x;
sum += x;
for (int i = 0; i < 2 * M; i++)
f[tp ^ 1][i] = f[tp][i];
for (int i = 0; i < 2 * M; i++){
if (f[tp][i] < 0) continue;
upd(f[tp ^ 1][i - x], f[tp][i]);
upd(f[tp ^ 1][i + x], f[tp][i] + x);
}
tp ^= 1;
}
cout << sum - f[tp][M];
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
1920 KB |
Output is correct |
2 |
Correct |
8 ms |
1920 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
1920 KB |
Output is correct |
2 |
Correct |
8 ms |
1920 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
1920 KB |
Output is correct |
2 |
Correct |
9 ms |
1920 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
1920 KB |
Output is correct |
2 |
Correct |
9 ms |
1920 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
1920 KB |
Output is correct |
2 |
Correct |
9 ms |
1920 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
1920 KB |
Output is correct |
2 |
Correct |
18 ms |
1920 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
1920 KB |
Output is correct |
2 |
Correct |
21 ms |
1920 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
79 ms |
1920 KB |
Output is correct |
2 |
Correct |
91 ms |
1920 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
125 ms |
1920 KB |
Output is correct |
2 |
Correct |
155 ms |
1920 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
176 ms |
1920 KB |
Output is correct |
2 |
Correct |
264 ms |
1952 KB |
Output is correct |