Submission #935090

#TimeUsernameProblemLanguageResultExecution timeMemory
935090ind1vIce Hockey World Championship (CEOI15_bobek)C++11
100 / 100
417 ms10548 KiB
#include <bits/stdc++.h> using namespace std; int n; long long m; vector<long long> c; vector<long long> a, b; vector<long long> c1; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n >> m; c.resize(n); for (int i = 0; i < n; i++) { cin >> c[i]; } for (int i = 0; i < n / 2; i++) { a.emplace_back(c.back()); c.pop_back(); } while (!c.empty()) { b.emplace_back(c.back()); c.pop_back(); } for (int msk = 0; msk < (1 << a.size()); msk++) { long long s = 0; for (int i = 0; i < a.size(); i++) { if (msk >> i & 1) { s += a[i]; } } c1.emplace_back(s); } sort(c1.begin(), c1.end()); long long ans = 0; for (int msk = 0; msk < (1 << b.size()); msk++) { long long s = 0; for (int i = 0; i < b.size(); i++) { if (msk >> i & 1) { s += b[i]; } } ans += (upper_bound(c1.begin(), c1.end(), m - s) - c1.begin()); } cout << ans << '\n'; return 0; }

Compilation message (stderr)

bobek.cpp: In function 'int main()':
bobek.cpp:29:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     for (int i = 0; i < a.size(); i++) {
      |                     ~~^~~~~~~~~~
bobek.cpp:40:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |     for (int i = 0; i < b.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...