Submission #1005002

#TimeUsernameProblemLanguageResultExecution timeMemory
1005002Muaath_5Ice Hockey World Championship (CEOI15_bobek)C++17
10 / 100
284 ms9808 KiB
#include <bits/stdc++.h> #define ll long long #define pii pair<int, int> using namespace std; const int N = 2e5+1; int n; ll m, a[N]; int main() { ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); cin >> n >> m; for (int i = 0; i < n; cin >> a[i++]); vector<ll> sums; for (int msk = 0; msk < (1 << (n/2)); msk++) { ll sum = 0; for (int i = 0; i < n/2; i++) { if (msk>>i&1) { sum += a[i]; } } sums.push_back(sum); } sort(sums.begin(), sums.end()); ll sol = 0; for (int msk = 0; msk < (1 << (n/2 + n%2)); msk++) { ll sum = 0; for (int i = 0; i < n/2+n%2; i++) { if (msk>>i&1) { sum += a[n/2+i]; } } int idx = upper_bound(sums.begin(), sums.end(), m-sum)-sums.begin(); assert(sum + sums[idx - 1] <= m); sol += idx; } cout << sol; }
#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...