Submission #1121525

#TimeUsernameProblemLanguageResultExecution timeMemory
1121525vjudge1Ice Hockey World Championship (CEOI15_bobek)C++17
50 / 100
479 ms8768 KiB
#include"bits/stdc++.h" using namespace std; using ll = long long; const int mxN = 40; int 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:1: 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...