Submission #376199

#TimeUsernameProblemLanguageResultExecution timeMemory
376199YJUIce Hockey World Championship (CEOI15_bobek)C++14
100 / 100
239 ms16896 KiB
#include<bits/stdc++.h> #pragma GCC optimize("unroll-loops,no-stack-protector,Ofast") using namespace std; typedef long long ll; typedef pair<ll,ll> pll; typedef long double ld; const ll N=(1LL<<20)+1; const ll MOD=1e9+7; const ll INF=(1LL<<61); const ld pi=acos(-1); #define REP(i,n) for(int i=0;i<n;++i) #define REP1(i,n) for(int i=1;i<=n;++i) #define pb push_back #define mp make_pair #define X first #define Y second #define lwb lower_bound #define SZ(_a) (ll)_a.size() #define count(_a) (ll)__builtin_popcount(_a) ll num,k,n,m,ans,id,a[N],b[N]; int main(){ ios_base::sync_with_stdio(0);cin.tie(0); cin>>num>>k; n=num/2,m=num-n; REP(i,n)cin>>a[1<<i]; REP(i,m)cin>>b[1<<i]; for(int i=0;i<(1<<n);i++){ a[i]=a[i^(i&-i)]+a[(i&-i)]; } for(int i=0;i<(1<<m);i++){ b[i]=b[i^(i&-i)]+b[(i&-i)]; } n=(1<<n),m=(1<<m); sort(a,a+n,greater<ll> ()); sort(b,b+m); REP(i,n){ while(id<m&&b[id]+a[i]<=k)++id; ans+=id; } cout<<ans<<"\n"; 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...