Submission #1121620

#TimeUsernameProblemLanguageResultExecution timeMemory
1121620vjudge1Ice Hockey World Championship (CEOI15_bobek)C++17
100 / 100
755 ms69136 KiB
#include <bits/stdc++.h> // #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops") // #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #define int long long #define ll long long #define pii pair<int, int> #define all(v) v.begin(), v.end() using namespace std; const int oo = 1e18 + 9; const int MAX = 3e5 + 5, LOGMAX = 20, B = 441, MOD = 998244353; void solve(){ int n, m; cin >> n >> m; int arr[n + 1]; for(int i = 0; i < n; i++){ cin >> arr[i]; } unordered_map<int, int> mp; int p1 = n / 2; int p2 = n - p1; for(int mask = 0; mask < (1 << p1); mask++){ int sum = 0; for(int i = 0; i < p1; i++){ if((1 << i) & mask) sum += arr[i]; } mp[sum]++; } vector<pii> v; for(auto a : mp){ v.push_back(a); } sort(v.begin(), v.end()); int p = 0; for(pii &a : v){ p += a.second; a.second = p; } int ans = 0; for(int mask = 0; mask < (1 << p2); mask++){ int sum = 0; for(int i = 0; i < p2; i++){ if((1 << i) & mask) sum += arr[p1 + i]; } if(sum > m) continue; ans += (upper_bound(all(v), make_pair(m - sum, oo)) - 1)->second; } cout << ans << '\n'; } signed main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t = 1; // cin >> t; while(t--) solve(); }
#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...