# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
839084 |
2023-08-28T15:31:42 Z |
carot15 |
Kas (COCI17_kas) |
C++14 |
|
71 ms |
2140 KB |
// carot15
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) begin(x), end(x)
#define mp make_pair
#define cyd {cout<<"Yes";return;}
#define cyn {cout<<"No";return;}
const ll nmax=5e6+5;
const ll mod=1e9+7;
const int X[]={0,0,1,-1};
const int Y[]={-1,1,0,0};
bitset<nmax> bit;
int n,a[505],t=0;
void solve(){
cin>>n;
bit[0]=1;
for (int i=1;i<=n;i++){
cin>>a[i];
t+=a[i];
bit|=bit<<a[i];
}
ll ans=t;
for (int i=1;i<=t/2;i++){
if (bit[i]){
ll p=t-i*2;
if (bit[p])
ans=p;
}
}
cout<<ans+(t-ans)/2;
}
/*
z
t-z
*/
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
// freopen(".INP", "r", stdin);
// freopen(".OUT", "w", stdout);
int T=1;
// cin>>T;
while(T--){
solve();
cout<<'\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
2132 KB |
Output is correct |
2 |
Correct |
3 ms |
2132 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
2132 KB |
Output is correct |
2 |
Incorrect |
3 ms |
2132 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
2132 KB |
Output is correct |
2 |
Correct |
3 ms |
2132 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
2132 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
2132 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
2132 KB |
Output is correct |
2 |
Incorrect |
7 ms |
2132 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
2060 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
31 ms |
2140 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
44 ms |
2132 KB |
Output is correct |
2 |
Correct |
61 ms |
2132 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
71 ms |
2132 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |