Submission #101753

#TimeUsernameProblemLanguageResultExecution timeMemory
101753cheehengIce Hockey World Championship (CEOI15_bobek)C++14
100 / 100
406 ms20944 KiB
#include <bits/stdc++.h> using namespace std; long long A[45]; int main(){ int N; long long M; scanf("%d%lld", &N, &M); for(int i = 0; i < N; i ++){ scanf("%lld", &A[i]); } if(N <= 20){ vector<long long> sum1; for(int i = 0; i < (1<<N); i ++){ long long temp = 0; for(int j = 0; j < N; j ++){ if(i&(1<<j)){ temp += A[j]; } } sum1.push_back(temp); } sort(sum1.begin(), sum1.end()); printf("%lld", (long long)(upper_bound(sum1.begin(), sum1.end(), M)-sum1.begin())); }else{ vector<long long> sum1; for(int i = 0; i < (1<<20); i ++){ long long temp = 0; for(int j = 0; j < 20; j ++){ if(i&(1<<j)){ temp += A[j]; } } sum1.push_back(temp); } vector<long long> sum2; for(int i = 0; i < (1<<(N-20)); i ++){ long long temp = 0; for(int j = 0; j < (N-20); j ++){ if(i&(1<<j)){ temp += A[j+20]; } } sum2.push_back(temp); } sort(sum1.begin(), sum1.end()); sort(sum2.begin(), sum2.end()); long long ans = 0; for(int i = 0; i < (1<<20); i ++){ ans += upper_bound(sum2.begin(), sum2.end(), M-sum1[i])-sum2.begin(); } printf("%lld", ans); } }

Compilation message (stderr)

bobek.cpp: In function 'int main()':
bobek.cpp:9: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:12: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...