Submission #170881

#TimeUsernameProblemLanguageResultExecution timeMemory
170881sochoIce Hockey World Championship (CEOI15_bobek)C++14
100 / 100
418 ms21000 KiB
#include "bits/stdc++.h" using namespace std; int main() { long long n, m; cin >> n >> m; vector<long long> vc(n); for (long long i=0; i<n; i++) cin >> vc[i]; vector<long long> le, ri; for (long long i=0; i<n/2; i++) { le.push_back(vc[i]); // cout << "L " << i << endl; } for (long long i=n/2; i<n; i++) { ri.push_back(vc[i]); // cout << "R " << i << endl; } long long ls = le.size(), rs = ri.size(); vector<long long> les, ris; for (long long i=0; i<(1<<ls); i++) { long long sm = 0; for (long long j=0; j<ls; j++) { if (i & (1 << j)) sm += le[j]; } les.push_back(sm); } for (long long i=0; i<(1<<rs); i++) { long long sm = 0; for (long long j=0; j<rs; j++) { if (i & (1 << j)) sm += ri[j]; } ris.push_back(sm); } sort(les.begin(), les.end()); sort(ris.begin(), ris.end()); reverse(ris.begin(), ris.end()); long long valid = 0; long long pt = 0; for (int i=0; i<les.size(); i++) { long long mx = m - les[i]; while (pt < ris.size() && ris[pt] > mx) pt++; valid += (ris.size() - pt); } cout << valid << endl; }

Compilation message (stderr)

bobek.cpp: In function 'int main()':
bobek.cpp:46:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i=0; i<les.size(); i++) {
                ~^~~~~~~~~~~
bobek.cpp:48:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   while (pt < ris.size() && ris[pt] > mx) pt++;
          ~~~^~~~~~~~~~~~
#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...