Submission #920850

#TimeUsernameProblemLanguageResultExecution timeMemory
920850dwuyIce Hockey World Championship (CEOI15_bobek)C++14
100 / 100
205 ms16852 KiB
#include <bits/stdc++.h> #define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL) #define file(a) freopen(a".inp","r",stdin); freopen(a".out", "w",stdout) #define fi first #define se second #define endl "\n" #define len(s) int32_t(s.length()) #define MASK(k)(1LL<<(k)) #define TASK "" #define int long long using namespace std; typedef tuple<int, int, int> tpiii; typedef pair<double, double> pdd; typedef pair<int, int> pii; typedef long long ll; const long long OO = 1e18; const int MOD = 1e9 + 7; const int INF = 1e9; const int MX = 41; int n, m; int a[MX]; int f1[MASK(20) + 5]; int f2[MASK(20) + 5]; void nhap(){ cin >> n >> m; for(int i=1; i<=n; i++) cin >> a[i]; } void solve(){ int mid = n>>1; int id1, id2; id1 = id2 = 0; for(int mask=0; mask<MASK(mid); mask++){ id1++; for(int f=mask; f; f-=-f&f){ int i = __lg(-f&f) + 1; f1[id1] += a[i]; } } for(int mask=0; mask<MASK(n - mid); mask++){ id2++; for(int f=mask; f; f-=-f&f){ int i = __lg(-f&f) + mid + 1; f2[id2] += a[i]; } } sort(f1+1, f1+id1+1); sort(f2+1, f2+id2+1); int ans = 0; for(int i=1; i<=id1; i++){ while(id2 >= 1 && f1[i] + f2[id2] > m) id2--; ans += f1[i] + f2[id2] <= m? id2 : 0; } cout << ans; } int32_t main(){ fastIO; // file(TASK); nhap(); solve(); 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...