Submission #732043

#TimeUsernameProblemLanguageResultExecution timeMemory
732043vjudge1Kas (COCI17_kas)C++11
70 / 100
2075 ms119452 KiB
#include <bits/stdc++.h> using namespace std; map<array<int, 4>, bool> done; const int MxN = 220; int n, answer; int a[MxN]; void rec(int state, int kang, int pun, int remain){ if(done[{state, kang, pun, remain}]){ return ; } done[{state, kang, pun, remain}] = true; if(state == n + 1){ if(kang == pun && kang != 0){ answer = max(answer, kang); } return ; } rec(state + 1, kang + a[state], pun, remain); rec(state + 1, kang, pun + a[state], remain); rec(state + 1, kang, pun, remain + a[state]); } int main() { cin.tie(nullptr)->ios::sync_with_stdio(false); int q = 1; //cin >> q; while(q--){ done.clear(); cin >> n; int all = 0; for(int i=1; i<=n; ++i){ cin >> a[i]; all += a[i]; } answer = 0; rec(1, 0, 0, 0); cout << answer + (all - answer * 2) << "\n"; } 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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...