# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
287514 |
2020-08-31T18:26:25 Z |
FlashGamezzz |
Kas (COCI17_kas) |
C++17 |
|
165 ms |
88440 KB |
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <string>
#include <utility>
#include <vector>
using namespace std;
bool dpf[501][100001] = {}, dpb[501][100001] = {};
int n;
long sum, notes[500];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n;
for (int i = 0; i < n; i++){
cin >> notes[i];
sum += notes[i];
}
dpf[0][0] = true;
for (int i = 1; i <= n; i++){
for (long j = 0; j < 100001; j++){
dpf[i][j] = dpf[i-1][j];
if (j >= notes[i-1]){
dpf[i][j] = dpf[i][j] || dpf[i-1][j-notes[i-1]];
}
}
}
dpb[n][0] = true;
for (int i = n-1; i >= 0; i--){
for (long j = 0; j < 100001; j++){
dpb[i][j] = dpb[i+1][j];
if (j >= notes[i]){
dpb[i][j] = dpb[i][j] || dpb[i+1][j-notes[i]];
}
}
}
long me = 0;
for (int i = 0; i <= n; i++){
for (long j = 0; j < 10001; j++){
if (dpf[i][j] && dpb[i][j]){
me = max(me, j);
}
}
}
cout << sum-me << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
2432 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
2304 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
2304 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
2688 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
2944 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
15 ms |
7168 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
17 ms |
9216 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
74 ms |
39544 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
114 ms |
59128 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
165 ms |
88440 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |