Submission #2780

#TimeUsernameProblemLanguageResultExecution timeMemory
2780kk1401속이기 (GA5_fake)C++98
10 / 100
1000 ms91200 KiB
#include<stdio.h> int n,d[2097153],cnt[2097153],ans,chk[2097153]; struct data { int x,y; }; data dy[2][2097153],cost[2][2097153]; void input() { int i; scanf("%d",&n); for(i=1; i<=n; i++) scanf("%d",&d[i]); } int maxval(int a,int b) { return a>b?a:b; } void process() { int i,j,in; dy[1][++cnt[1]].x=cost[1][1].x=d[1]; dy[1][cnt[1]].y=-1; cost[1][1].y=0; for(i=2; i<=n; i++){ for(j=1; j<=cnt[i-1]; j++){ //x에 넣는경우 in = i%2; if(chk[dy[1-in][j].x^d[i]] != i){ dy[in][++cnt[i]].x = dy[1-in][j].x^d[i]; dy[in][cnt[i]].y = dy[1-in][j].y; cost[in][cnt[i]].y = cost[1-in][j].y; cost[in][cnt[i]].x = cost[1-in][j].x + d[i]; chk[dy[1-in][j].x^d[i]]=i; } if(chk[dy[1-in][j].x] != i){ //y에 넣는경우 if(dy[1-in][j].y==-1) dy[in][++cnt[i]].y = d[i]; else dy[in][++cnt[i]].y = dy[1-in][j].y^d[i]; dy[in][cnt[i]].x = dy[1-in][j].x; cost[in][cnt[i]].y = cost[1-in][j].y + d[i]; cost[in][cnt[i]].x = cost[1-in][j].x; chk[dy[1-in][j].x] = i; } } } for(i=1; i<=cnt[n]; i++) if(dy[n%2][i].x==dy[n%2][i].y) ans=maxval(ans,maxval(cost[n%2][i].x,cost[n%2][i].y)); } void output() { printf("%d\n",ans); } int main() { input(); process(); output(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...