이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <stdio.h>
#define X 1
#define Y 2
int n, a[1200], xXor = 0, yXor = 0, xTotal = 0, xCount = 0, answer = 0;
void Process(int index, int where);
int main()
{
scanf("%d", &n);
for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
Process(1, X);
Process(1, Y);
printf("%d", answer);
}
void Process(int index, int where)
{
if(index < n)
{
xTotal += a[index];
xXor ^= a[index];
xCount++;
Process(index+1, X);
xTotal -= a[index];
xXor ^= a[index];
xCount--;
yXor ^= a[index];
Process(index+1, Y);
yXor ^= a[index];
}
else
{
if((xXor ^ a[index]) == yXor && answer < xTotal + a[index] && xCount+1 != n) answer = xTotal + a[index];
if(xXor == (yXor ^ a[index]) && answer < xTotal && xCount != 0) answer = xTotal;
}
}
# | 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... |