제출 #527901

#제출 시각아이디문제언어결과실행 시간메모리
527901aSSSdKas (COCI17_kas)C++14
0 / 100
200 ms196820 KiB
#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); int n; int c[502]; int g[502][100000 + 10]; int go(int k, int diff) { if(diff >= 100000+5) return -1e9; if(g[k][diff] != - 1) return g[k][diff]; int &ret = g[k][diff]; if(k == n+1) { return ret = (diff == 0 ? 0 : -1e9); } ret = max(ret , go(k+1 , diff + c[k]) + c[k]); ret = max(ret , go(k+1 , abs(diff - c[k]) ) + c[k]); ret = max(ret , go(k+1 , diff)); return ret; } main() { fasty; cin >> n; int sum=0; forinc(i,1,n) { cin >> c[i]; sum+=c[i]; } memset(g , -1 , sizeof g); int split = go(1,0); cout << (sum - split) + split/2; }

컴파일 시 표준 에러 (stderr) 메시지

kas.cpp:37:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   37 | main()
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...