Submission #101754

#TimeUsernameProblemLanguageResultExecution timeMemory
101754jamielimIce Hockey World Championship (CEOI15_bobek)C++14
100 / 100
475 ms8668 KiB
#include <bits/stdc++.h> using namespace std; int n; long long m; long long arr[45]; int k,l; int main(){ scanf("%d%lld",&n,&m); for(int i=0;i<n;i++)scanf("%lld",&arr[i]); k=n/2; l=n-k; long long fh[(1<<k)]; for(int i=0;i<(1<<k);i++){ int bm=i; long long cur=0; while(bm&(-bm)){ cur+=arr[__builtin_ctz(bm)]; bm-=(bm&(-bm)); } fh[i]=cur; } sort(fh,fh+(1<<k)); long long ans=0; for(int i=0;i<(1<<l);i++){ int bm=i; long long cur=0; while(bm&(-bm)){ cur+=arr[__builtin_ctz(bm)+k]; bm-=(bm&(-bm)); } cur=m-cur; ans+=upper_bound(fh,fh+(1<<k),cur)-fh; } printf("%lld",ans); }

Compilation message (stderr)

bobek.cpp: In function 'int main()':
bobek.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%lld",&n,&m);
     ~~~~~^~~~~~~~~~~~~~~~
bobek.cpp:11:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=0;i<n;i++)scanf("%lld",&arr[i]);
                         ~~~~~^~~~~~~~~~~~~~~~
#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...