# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
994033 |
2024-06-07T04:34:51 Z |
vjudge1 |
Kas (COCI17_kas) |
C++17 |
|
63 ms |
77316 KB |
#include <bits/stdc++.h>
using namespace std;
const int M = 1e5 + 1, N = 500 + 1, inf = 1e9;
int cnt[M],ans,pre[N][M*2],temp[M*2];
int main()
{
int n,x;
cin>>n;
for (int i=0;i<n;i++)
cin>>x,cnt[x]++;
for (int i=1;i<M;i++)
ans+=(cnt[i]/2)*i,cnt[i]%=2;
int su=0;
vector<int> a;
for (int i=1;i<M;i++)
if (cnt[i])
su+=i,a.push_back(i);
n=a.size();
for (int i=0;i<M*2;i++)
temp[i]=pre[0][i]=-inf;
temp[M]=pre[0][M]=0;
for (int i=0;i<n;i++)
{
for (int j=0;j<M*2;j++)
{
if (j+a[i]<M*2)
temp[j+a[i]]=max(temp[j+a[i]],pre[i][j]+a[i]);
if (j-a[i]>=0)
temp[j-a[i]]=max(temp[j-a[i]],pre[i][j]+a[i]);
}
for (int j=0;j<M*2;j++)
pre[i+1][j]=temp[j];
}
int div=pre[n][M];
cout<<ans+div/2+su-div<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
10076 KB |
Output is correct |
2 |
Incorrect |
6 ms |
8436 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
10076 KB |
Output is correct |
2 |
Correct |
9 ms |
10076 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
8540 KB |
Output is correct |
2 |
Incorrect |
7 ms |
9400 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
11608 KB |
Output is correct |
2 |
Incorrect |
6 ms |
7768 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
9308 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
12376 KB |
Output is correct |
2 |
Correct |
5 ms |
7004 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
9308 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
43 ms |
53844 KB |
Output is correct |
2 |
Correct |
20 ms |
24156 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
27 ms |
33616 KB |
Output is correct |
2 |
Incorrect |
49 ms |
63316 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
63 ms |
77316 KB |
Output is correct |
2 |
Incorrect |
58 ms |
67924 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |