Submission #1122264

#TimeUsernameProblemLanguageResultExecution timeMemory
1122264I_love_BanuIce Hockey World Championship (CEOI15_bobek)C++14
100 / 100
390 ms8656 KiB
#include"bits/stdc++.h" using namespace std; using ll = long long; const int mxN = 40; ll a[mxN]; main() { int N; ll M; cin >> N >> M; for (int i = 0; i < N; i ++) { cin >> a[i]; } int firstHalf = N / 2; vector<ll> poss; for (int i = 0; i < (1 << firstHalf); i ++) { ll sm = 0; for (int j = 0; j < firstHalf; j ++) { if ((i >> j) & 1) { sm += a[j]; } } poss.push_back(sm); } sort(begin(poss),end(poss)); int secondHalf = N - firstHalf; ll ans = 0; for (int i = 0; i < (1 << secondHalf); i ++) { ll sm = 0; for (int j = 0; j < secondHalf; j ++) { if ((i >> j) & 1) { sm += a[firstHalf + j]; } } ans += upper_bound(begin(poss),end(poss),M - sm) - begin(poss); } cout << ans << endl; }

Compilation message (stderr)

bobek.cpp:10:5: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   10 |     main() {
      |     ^~~~
#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...