Submission #250744

#TimeUsernameProblemLanguageResultExecution timeMemory
250744WhaleVomitIce Hockey World Championship (CEOI15_bobek)C++14
100 / 100
564 ms20872 KiB
#include <bits/stdc++.h> using namespace std; #define f first #define s second #define pb push_back #define mp make_pair #define all(v) v.begin(), v.end() #define sz(v) (int)v.size() #define MOO(i, a, b) for(int i=a; i<b; i++) #define M00(i, a) for(int i=0; i<a; i++) #define MOOd(i,a,b) for(int i = (b)-1; i >= a; i--) #define M00d(i,a) for(int i = (a)-1; i>=0; i--) #define FAST ios::sync_with_stdio(0); cin.tie(0); #define finish(x) return cout << x << '\n', 0; #define dbg(x) cerr << ">>> " << #x << " = " << x << "\n"; #define _ << " _ " << template<class T> bool ckmin(T& a, const T& b) {return b < a ? a = b, 1 : 0;} template<class T> bool ckmax(T& a, const T& b) {return a < b ? a = b, 1 : 0;} typedef long long ll; typedef long double ld; typedef vector<int> vi; typedef pair<int,int> pi; typedef pair<ld,ld> pd; typedef complex<ld> cd; const int MAX_N = 44; int n; ll mx; ll arr[MAX_N]; vector<ll> cnt1; vector<ll> cnt2; int main() { FAST cin >> n >> mx; M00(i, n) cin >> arr[i]; M00(i, 1<<(n/2)) { ll s = 0; M00(j, n/2) if(i & (1<<j)) s += arr[j]; cnt1.pb(s); } M00(i, 1<<(n-n/2)) { ll s = 0; M00(j, n-n/2) if(i & (1<<j)) s += arr[n/2 + j]; cnt2.pb(s); } sort(all(cnt2)); ll res = 0; for(ll x: cnt1) { ll ub = mx - x; int lo = -1; int hi = sz(cnt2); while(lo+1 != hi) { int mid = (lo + hi)/2; if(cnt2[mid] <= ub) lo = mid; else hi = mid; } res += lo+1; } finish(res); }
#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...