Submission #101761

#TimeUsernameProblemLanguageResultExecution timeMemory
101761rocketninja7Ice Hockey World Championship (CEOI15_bobek)C++14
100 / 100
234 ms16860 KiB
#include <cstdio> #include <algorithm> using namespace std; int main(){ int N; long long int M; scanf("%d%lld", &N, &M); long long int A[N]; for(int i=0;i<N;i++){ scanf("%lld", &A[i]); } long long int sums1[1<<(N/2)]; for(int i=0;i<(1<<(N/2));i++){ sums1[i]=1000000000000000001; long long int temp=0; long long int tempI=i; while(tempI>0){ temp+=A[__builtin_ctz(tempI)]; if(temp>M){ break; } tempI-=tempI&-tempI; } if(temp<=M){ sums1[i]=temp; } } long long int sums2[1<<(N-N/2)]; for(int i=0;i<(1<<(N-N/2));i++){ sums2[i]=1000000000000000001; long long int temp=0; long long int tempI=i; while(tempI>0){ temp+=A[__builtin_ctz(tempI)+N/2]; if(temp>M){ break; } tempI-=tempI&-tempI; } if(temp<=M){ sums2[i]=temp; } } sort(sums1, sums1+(1<<(N/2))); sort(sums2, sums2+(1<<(N-N/2))); long long int ans=0; int ri=(1<<(N-N/2))-1; for(int i=0;i<(1<<(N/2));i++){ while(ri>-1&&sums1[i]+sums2[ri]>M){ ri--; } ans+=ri+1; } printf("%lld", ans); return 0; }

Compilation message (stderr)

bobek.cpp: In function 'int main()':
bobek.cpp:7: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:10:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld", &A[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...