#include<stdio.h>
int n,d[1001],cnt[1001],ans;
struct data
{
int x,y;
}; data dy[1001][1001],cost[1001][1001];
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;
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에 넣는경우
dy[i][++cnt[i]].x = dy[i-1][j].x^d[i];
dy[i][cnt[i]].y = dy[i-1][j].y;
cost[i][cnt[i]].y = cost[i-1][j].y;
cost[i][cnt[i]].x = cost[i-1][j].x + d[i];
//y에 넣는경우
if(dy[i-1][j].y==-1) dy[i][++cnt[i]].y = d[i];
else dy[i][++cnt[i]].y = dy[i-1][j].y^d[i];
dy[i][cnt[i]].x = dy[i-1][j].x;
cost[i][cnt[i]].y = cost[i-1][j].y + d[i];
cost[i][cnt[i]].x = cost[i-1][j].x;
}
}
for(i=1; i<=cnt[n]; i++) if(dy[n][i].x==dy[n][i].y) ans=maxval(ans,maxval(cost[n][i].x,cost[n][i].y));
}
void output()
{
printf("%d\n",ans);
}
int main()
{
input();
process();
output();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
16752 KB |
Output is correct |
2 |
Correct |
0 ms |
16752 KB |
Output is correct |
3 |
Correct |
0 ms |
16752 KB |
Output is correct |
4 |
Correct |
0 ms |
16752 KB |
Output is correct |
5 |
Incorrect |
0 ms |
16752 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
12 ms |
16748 KB |
SIGSEGV Segmentation fault |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
4 ms |
16748 KB |
SIGSEGV Segmentation fault |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
4 ms |
16748 KB |
SIGSEGV Segmentation fault |
2 |
Halted |
0 ms |
0 KB |
- |