Submission #259613

#TimeUsernameProblemLanguageResultExecution timeMemory
259613BertedIce Hockey World Championship (CEOI15_bobek)C++14
100 / 100
242 ms20840 KiB
#include <iostream> #include <vector> #include <algorithm> #define ll long long using namespace std; int n; ll m, ar[41], res = 0; vector<ll> pos[2]; void rs(int s, int l, ll k, int id) { if (s < l) { rs(s + 1, l, k, id); rs(s + 1, l, k + ar[s], id); } else {pos[id].push_back(k);} } int main() { cin >> n >> m; for (int i = 0; i < n; i++) cin >> ar[i]; rs(0, n / 2, 0, 0); rs(n / 2, n, 0, 1); sort(pos[0].begin(), pos[0].end()); sort(pos[1].begin(), pos[1].end()); ll R = pos[1].size() - 1; for (int i = 0; i < pos[0].size(); i++) { while (R >= 0 && pos[0][i] + pos[1][R] > m) {R--;} res += (R + 1); } cout << res << "\n"; return 0; }

Compilation message (stderr)

bobek.cpp: In function 'int main()':
bobek.cpp:29:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < pos[0].size(); 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...