# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
897613 | mihtriii295 | Kas (COCI17_kas) | C++17 | 65 ms | 2652 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#pragma GCC optimize("O2")
#define ll long long
#define TIME (1.0 * clock() / CLOCKS_PER_SEC)
#define el cout << '\n'
using namespace std;
const ll N = 1e8 + 1;
const ll logN = 20;
const ll MOD = 1e9 + 7;
int n, a[N], res, f[N], sum;
int main(){
if(fopen("coci1617_r4_kas.inp", "r")){
freopen("coci1617_r4_kas.inp", "r", stdin);
freopen("coci1617_r4_kas.out", "w", stdout);
}
ios_base::sync_with_stdio(0); cin.tie(NULL);
cout.tie(NULL);
cin >> n;
f[0] = 1;
for (int i = 1; i <= n; ++i){
cin >> a[i];
sum += a[i];
}
for (int i = 1; i <= n; ++i){
for (int j = 2 * sum; j >= a[i]; --j)
if (f[j - a[i]] == 1)
f[j] = 1;
}
for (int i = 2 * sum; i >= 0; --i){
if (i & 1)
continue;
if (f[i] == 1 && f[i / 2] == 1){
cout << i / 2 + sum - i;
break;
}
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |