# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
448532 |
2021-07-30T12:41:08 Z |
rainboy |
Kas (COCI17_kas) |
C |
|
181 ms |
1860 KB |
#include <stdio.h>
#include <string.h>
#define S 100000
int max(int a, int b) { return a > b ? a : b; }
int main() {
static int dp[S * 2 + 1], dq[S * 2 + 1];
int n, sum;
scanf("%d", &n);
memset(dp, -1, (S * 2 + 1) * sizeof *dp), dp[S] = 0;
sum = 0;
while (n--) {
int c, s;
scanf("%d", &c);
sum += c;
memcpy(dq, dp, (S * 2 + 1) * sizeof *dp);
for (s = 0; s <= S * 2; s++)
if (dp[s] != -1)
dq[s - c] = max(dq[s - c], dp[s] + c), dq[s + c] = max(dq[s + c], dp[s] + c);
memcpy(dp, dq, (S * 2 + 1) * sizeof *dq);
}
printf("%d\n", sum - dp[S] / 2);
return 0;
}
Compilation message
kas.c: In function 'main':
kas.c:12:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
12 | scanf("%d", &n);
| ^~~~~~~~~~~~~~~
kas.c:18:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
18 | scanf("%d", &c);
| ^~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
1740 KB |
Output is correct |
2 |
Correct |
4 ms |
1740 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1740 KB |
Output is correct |
2 |
Correct |
4 ms |
1740 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
1740 KB |
Output is correct |
2 |
Correct |
4 ms |
1728 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
1740 KB |
Output is correct |
2 |
Correct |
5 ms |
1740 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
1740 KB |
Output is correct |
2 |
Correct |
5 ms |
1740 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
1836 KB |
Output is correct |
2 |
Correct |
11 ms |
1740 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
1836 KB |
Output is correct |
2 |
Correct |
16 ms |
1840 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
62 ms |
1860 KB |
Output is correct |
2 |
Correct |
68 ms |
1740 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
87 ms |
1748 KB |
Output is correct |
2 |
Correct |
122 ms |
1816 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
148 ms |
1820 KB |
Output is correct |
2 |
Correct |
181 ms |
1820 KB |
Output is correct |