Submission #858957

#TimeUsernameProblemLanguageResultExecution timeMemory
858957Tenis0206Ice Hockey World Championship (CEOI15_bobek)C++11
50 / 100
291 ms22712 KiB
#include <bits/stdc++.h> using namespace std; const int nmax = 40; int n,m; int v[nmax + 5]; int main() { ios::sync_with_stdio(false); cin.tie(0); cin>>n>>m; for(int i=1;i<=n;i++) { cin>>v[i]; } int sz_a = n / 2; int sz_b = n - sz_a; vector<long long> a,b; for(int mask=0;mask<(1<<sz_a);mask++) { long long sum = 0; for(int b=0;b<sz_a;b++) { if((mask & (1<<b))!=0) { sum += v[b + 1]; } } a.push_back(sum); } for(int mask=0;mask<(1<<sz_b);mask++) { long long sum = 0; for(int b=0;b<sz_b;b++) { if((mask & (1<<b))!=0) { sum += v[sz_a + b + 1]; } } b.push_back(sum); } sort(a.begin(),a.end()); sort(b.begin(),b.end()); int poz = b.size() - 1; long long rez = 0; for(int i=0;i<a.size();i++) { while(poz >= 0 && a[i] + b[poz] > m) { --poz; } rez += poz + 1; } cout<<rez<<'\n'; return 0; }

Compilation message (stderr)

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