Submission #63774

#TimeUsernameProblemLanguageResultExecution timeMemory
63774khohkoIce Hockey World Championship (CEOI15_bobek)C++17
100 / 100
469 ms17492 KiB
#include<bits/stdc++.h> //#pragma GCC optimize("O3") using namespace std; #define ll long long #define pb push_back #define fr first #define sc second #define ARRS ((ll)(2e6+500)) #define MAX ((ll)(1e6+100)) #define MOD ((ll)1e6+7) #define mi(a,b) a=min((a),(b)) ll n,m,k,p,l,r,q; ll a[ARRS]; ll b[ARRS]; ll s[ARRS]; ll es[ARRS]; int main(){ #ifdef KHOKHO freopen("in.in","r",stdin); freopen("out.out","w",stdout); #endif ios::sync_with_stdio(0); ll S; cin>>n>>S; ll m=n/2; n=n-m; for(int i=0; i<n; i++)cin>>a[i]; for(int i=0; i<m; i++)cin>>b[i]; for(int i=0; i<(1<<n); i++) for(int t=0; t<n; t++) if((i>>t)&1)s[i]+=a[t]; for(int i=0; i<(1<<m); i++) for(int t=0; t<m; t++) if((i>>t)&1)es[i]+=b[t]; sort(s,s+(1<<n)); sort(es,es+(1<<m)); ll pas=0; for(int i=0; i<(1<<n); i++){ pas+=upper_bound(es,es+(1<<m),S-s[i])-es; } cout<<pas; }
#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...