Submission #994141

#TimeUsernameProblemLanguageResultExecution timeMemory
994141vjudge1Kas (COCI17_kas)C++17
0 / 100
47 ms6668 KiB
#include <bits/stdc++.h> using namespace std; const int N = 505; const int S = 1e5 + 10; int n, a[N]; bitset<N> B[S]; bool dp[S]; int main(){ cin >> n; int total = 0; for (int i = 0; i < n; i ++) cin >> a[i], total += a[i]; sort(a, a + n); dp[0] = 1; int mx = 0; for (int i = 0; i < n; i ++){ for (int sm = total; sm >= a[i]; sm--){ if (!dp[sm - a[i]]) continue; if (dp[sm]){ bitset<N> b = B[sm - a[i]]; b[i] = 1; b &= B[sm]; if (!(b.any())) mx = max(mx, sm); } else{ dp[sm] = 1; B[sm] = B[sm - a[i]]; B[sm][i] = 1; } } } cout << total - mx << endl; }
#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...