Submission #2774

#TimeUsernameProblemLanguageResultExecution timeMemory
2774mhkim4886속이기 (GA5_fake)C++98
10 / 100
1000 ms1092 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...