Submission #564195

#TimeUsernameProblemLanguageResultExecution timeMemory
564195piOOEIce Hockey World Championship (CEOI15_bobek)C++17
100 / 100
530 ms8532 KiB
#include <bits/stdc++.h> using namespace std; #define all(x) begin(x), end(x) #define sz(x) ((int)size(x)) #define trace(x) cout << #x << ": " << (x) << endl; typedef long long ll; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; ll m; cin >> n >> m; int L = n / 2, R = n - L; vector<ll> x(1 << R), a(n); for (int i = 0; i < n; ++i) cin >> a[i]; for (int mask = 0; mask < (1 << R); ++mask) { for (int i = 0; i < R; ++i) { if ((mask >> i) & 1) { x[mask] += a[i + L]; } } } sort(all(x)); ll ans = 0; for (int mask = 0; mask < (1 << L); ++mask) { ll sum = 0; for (int i = 0; i < L; ++i) { if ((mask >> i) & 1) sum += a[i]; } ans += upper_bound(all(x), m - sum) - begin(x); } cout << ans; 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...