제출 #442942

#제출 시각아이디문제언어결과실행 시간메모리
442942zxcvbnmKas (COCI17_kas)C++14
30 / 100
2086 ms312 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]; } int mx = 0, sz = 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(); if (accumulate(b.begin(), b.end(), 0) % 2 || m < sz) 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; sz = m; 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...