Submission #221858

#TimeUsernameProblemLanguageResultExecution timeMemory
221858PeppaPigIce Hockey World Championship (CEOI15_bobek)C++14
100 / 100
541 ms20820 KiB
#include <bits/stdc++.h> #define long long long using namespace std; vector<long> process(vector<long> &v) { vector<long> ret; for(int i = 0; i < (1 << (int)v.size()); i++) { long now = 0; for(int j = 0; j < v.size(); j++) if(i >> j & 1) now += v[j]; ret.emplace_back(now); } return ret; } int n; long m; int main() { scanf("%d %lld", &n, &m); vector<long> l, r; long a; for(int i = 1; i <= n / 2; i++) { scanf("%lld", &a); l.emplace_back(a); } for(int i = n / 2 + 1; i <= n; i++) { scanf("%lld", &a); r.emplace_back(a); } vector<long> sum_l = process(l); vector<long> sum_r = process(r); sort(sum_l.begin(), sum_l.end()); long ans = 0; for(long x : sum_r) ans += upper_bound(sum_l.begin(), sum_l.end(), m - x) - sum_l.begin(); printf("%lld\n", ans); return 0; }

Compilation message (stderr)

bobek.cpp: In function 'std::vector<long long int> process(std::vector<long long int>&)':
bobek.cpp:11:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int j = 0; j < v.size(); j++) if(i >> j & 1)
                        ~~^~~~~~~~~~
bobek.cpp: In function 'int main()':
bobek.cpp:22: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:26:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld", &a);
         ~~~~~^~~~~~~~~~~~
bobek.cpp:30:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld", &a);
         ~~~~~^~~~~~~~~~~~
#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...