Submission #138969

#TimeUsernameProblemLanguageResultExecution timeMemory
138969meatrowIce Hockey World Championship (CEOI15_bobek)C++17
100 / 100
587 ms8832 KiB
//#pragma GCC optimize("O3") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native") //#pragma GCC optimize ("unroll-loops") #include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int n; ll m; cin >> n >> m; vector<ll> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } int left_sz = n / 2, right_sz = n - left_sz; int topkek = 1 << right_sz; vector<ll> weights; for (int mask = 0; mask < topkek; mask++) { ll kek = 0; for (int i = 0; i < right_sz; i++) { if (mask & (1 << i)) { kek += a[left_sz + i]; } } weights.push_back(kek); } topkek = 1 << left_sz; ll ans = 0; sort(weights.begin(), weights.end()); for (int mask = 0; mask < topkek; mask++) { ll kek = 0; for (int i = 0; i < left_sz; i++) { if (mask & (1 << i)) { kek += a[i]; } } ans += upper_bound(weights.begin(), weights.end(), m - kek) - weights.begin(); } 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...