제출 #442945

#제출 시각아이디문제언어결과실행 시간메모리
442945zxcvbnmKas (COCI17_kas)C++14
50 / 100
22 ms468 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<int> a(n); for(int i = 0; i < n; i++) { cin >> a[i]; } assert(n <= 13); int mx = accumulate(a.begin(), a.end(), 0); int big_sum = 0; for(int mask = 0; mask < (1 << n); mask++) { vector<int> b; int curr = 0; for(int i = 0; i < n; i++) { if (mask & (1 << i)) { b.push_back(a[i]); } else { curr += a[i]; } } int m = b.size(); int k = accumulate(b.begin(), b.end(), 0); if (k % 2 || big_sum > k/2) continue; for(int mask2 = 0; mask2 < (1 << m); mask2++) { int sum1 = 0, sum2 = 0; for(int i = 0; i < m; i++) { if (mask2 & (1 << i)) { sum1 += b[i]; } else { sum2 += b[i]; } } if (sum1 == sum2) { mx = sum1 + curr; big_sum = sum1; break; } } } cout << mx << "\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...