Submission #1121586

#TimeUsernameProblemLanguageResultExecution timeMemory
1121586vjudge1Ice Hockey World Championship (CEOI15_bobek)C++17
100 / 100
362 ms20900 KiB
#include <bits/stdc++.h> #define ll long long #define endl "\n"; #define AI ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); using namespace std; int main() { AI ll n,m,i; cin>>n>>m; ll a[n]; for(i=0;i<n;i++) cin>>a[i]; vector<ll>h1; vector<ll>h2; for(ll mask=0;mask<(1<<(n/2));mask++) { ll sum=0; for(ll i=0;i<n/2;i++)//0 1 2 { if(mask&(1<<i)) sum+=a[i]; } if(sum<=m) h1.push_back(sum); } for(ll mask=0;mask<(1<<(n/2+n%2));mask++) { ll sum=0; for(ll i=0;i<n/2+n%2;i++)// { if(mask&(1<<i)) sum+=a[n/2+i]; } // cout<<mask<<' '<<sum<<endl; if(sum<=m) h2.push_back(sum); } sort(h1.begin(),h1.end()); sort(h2.begin(),h2.end()); ll say=0; /* for(i=0;i<h1.size();i++) cout<<h1[i]<<' '; cout<<endl; for(i=0;i<h2.size();i++) cout<<h2[i]<<' ';*/ for(i=0;i<h1.size();i++) say+=upper_bound(h2.begin(),h2.end(),m-h1[i])-h2.begin(); cout<<say; }

Compilation message (stderr)

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