This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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... |