# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1042910 |
2024-08-03T14:36:13 Z |
VMaksimoski008 |
Kas (COCI17_kas) |
C++17 |
|
220 ms |
392524 KB |
#include <iostream>
using namespace std;
const int M = 1e5 + 5;
int dp[505][2*M+5], v[505];
int main() {
int n, S = 0;
cin >> n;
for(int i=1; i<=n; i++) cin >> v[i], S += v[i];
for(int j=0; j<=2*M; j++) dp[0][j] = -1e9;
dp[0][M] = 0;
for(int i=1; i<=n; i++) {
for(int j=0; j<=2*M; j++) {
dp[i][j] = dp[i-1][j];
if(j + v[i] <= 2 * M) dp[i][j] = max(dp[i][j], dp[i-1][j+v[i]] + v[i]);
if(j - v[i] >= 0) dp[i][j] = max(dp[i][j], dp[i-1][j-v[i]] + v[i]);
}
}
cout << S - dp[n][M] / 2 << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
9052 KB |
Output is correct |
2 |
Correct |
5 ms |
9052 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
9052 KB |
Output is correct |
2 |
Correct |
5 ms |
9032 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
8888 KB |
Output is correct |
2 |
Correct |
5 ms |
9736 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
10588 KB |
Output is correct |
2 |
Correct |
7 ms |
11220 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
11356 KB |
Output is correct |
2 |
Correct |
7 ms |
11356 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
28508 KB |
Output is correct |
2 |
Correct |
19 ms |
32440 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
21 ms |
36444 KB |
Output is correct |
2 |
Correct |
24 ms |
40300 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
92 ms |
157724 KB |
Output is correct |
2 |
Correct |
123 ms |
196692 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
134 ms |
235856 KB |
Output is correct |
2 |
Correct |
175 ms |
314340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
194 ms |
353348 KB |
Output is correct |
2 |
Correct |
220 ms |
392524 KB |
Output is correct |