# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
527891 |
2022-02-18T16:20:41 Z |
aSSSd |
Kas (COCI17_kas) |
C++14 |
|
1365 ms |
432584 KB |
#include <bits/stdc++.h>
using namespace std;
#define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
#define fasty ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define forinc(x,a,b) for (int x=a;x<=b;x++)
#define fi first
#define se second
#define pb push_back
#define ii pair<int,int>
#define all(a) a.begin(),a.end()
#define reset(f,x) memset(f, x, sizeof(f))
#define getbit(x,i) ((x>>i)&1)
#define batbit(x,i) (x|(1ll<<i))
#define tatbit(x,i) (x&~(1<<i))
#define gg exit(0);
#define int long long
const int N = 55;
const int M = 1002;
int f[N][M][M];
int n;
int c[N];
int solve(int k, int a, int b)
{
if(f[k][a][b] != -1) return f[k][a][b];
int &ret = f[k][a][b];
if (k == n+1)
{
return ret = (a == b ? 0 : -1e9);
}
return ret = max({solve(k+1, a, b), solve(k+1, a+c[k], b)+c[k], solve(k+1, a, b+c[k])+c[k]});
}
main()
{
fasty;
cin >> n;
int sum=0;
forinc(i,1,n)
{
cin >> c[i];
sum+=c[i];
}
memset(f , -1 ,sizeof f);
int split = solve(1 , 0 , 0);
cout << (sum - split) + split/2;
}
Compilation message
kas.cpp:38:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
38 | main()
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
151 ms |
432512 KB |
Output is correct |
2 |
Correct |
153 ms |
432572 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
154 ms |
432452 KB |
Output is correct |
2 |
Correct |
158 ms |
432508 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
155 ms |
432584 KB |
Output is correct |
2 |
Correct |
153 ms |
432424 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
158 ms |
432452 KB |
Output is correct |
2 |
Correct |
153 ms |
432464 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
161 ms |
432576 KB |
Output is correct |
2 |
Correct |
170 ms |
432428 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
179 ms |
432460 KB |
Output is correct |
2 |
Correct |
179 ms |
432508 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
186 ms |
432436 KB |
Output is correct |
2 |
Correct |
187 ms |
432484 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1365 ms |
432548 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
164 ms |
432456 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
155 ms |
432488 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |