# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
994040 |
2024-06-07T04:49:33 Z |
vjudge1 |
Kas (COCI17_kas) |
C++17 |
|
52 ms |
2652 KB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int const N=5e5;
int const inf=1e9+7;
int diff[N];
int cpy[N];
void solve(){
int n;
cin>>n;
for (int i = 0; i <=100000; ++i)
diff[i]=-inf;
diff[0]=0;
int sm=0;
for(int e=0;e<n;e++){
int c;
cin>>c;
sm+=c;
for (int i = 0; i <=100000; ++i)
cpy[i]=diff[i];
for(int i=100000;i>=0;i--){
if(diff[i]<0)
continue;
cpy[i+c]=max(diff[i],cpy[i+c]);
if(i>=c)
cpy[i-c]=max(diff[i]+c,cpy[i-c]);
else
cpy[c-i]=max(diff[i]+i,cpy[c-i]);
}
for(int i=0;i<=100000;i++)
diff[i]=cpy[i];
}
cout<<sm-(diff[0])<<endl;
}
int main(){
int t=1;
// cin>>t;
while(t--)
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2652 KB |
Output is correct |
2 |
Correct |
1 ms |
2652 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2652 KB |
Output is correct |
2 |
Correct |
2 ms |
2652 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2652 KB |
Output is correct |
2 |
Correct |
1 ms |
2652 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2652 KB |
Output is correct |
2 |
Correct |
2 ms |
2652 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2648 KB |
Output is correct |
2 |
Correct |
2 ms |
2652 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
2652 KB |
Output is correct |
2 |
Correct |
4 ms |
2652 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
2648 KB |
Output is correct |
2 |
Correct |
4 ms |
2652 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
2648 KB |
Output is correct |
2 |
Correct |
17 ms |
2652 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
2652 KB |
Output is correct |
2 |
Correct |
29 ms |
2652 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
38 ms |
2652 KB |
Output is correct |
2 |
Correct |
52 ms |
2648 KB |
Output is correct |