Submission #928910

#TimeUsernameProblemLanguageResultExecution timeMemory
928910WarinchaiIce Hockey World Championship (CEOI15_bobek)C++14
100 / 100
300 ms21700 KiB
#include<bits/stdc++.h> #define int long long using namespace std; int ar[45]; vector<int>first; vector<int>second; int32_t main(){ ios_base::sync_with_stdio(false); cin.tie(0); int n,m;cin>>n>>m; int md=n/2; int m2=n-md; for(int i=1;i<=n;i++){ cin>>ar[i]; } for(int i=0;i<(1<<md);i++){ int sum=0; for(int j=0;j<md;j++){ if((i>>j)&1)sum+=ar[j+1]; } //cerr<<i<<" "<<sum<<"\n"; if(sum<=m)first.push_back(sum); } for(int i=0;i<(1<<m2);i++){ int sum=0; for(int j=0;j<m2;j++){ if((i>>j)&1)sum+=ar[md+j+1]; } if(sum<=m)second.push_back(sum); } sort(first.begin(),first.end()); sort(second.begin(),second.end(),greater<int>()); /*for(auto x:first)cerr<<x<<" "; cerr<<"\n"; for(auto x:second)cerr<<x<<" "; cerr<<"\n";*/ int cur=0; int ans=0; for(auto x:first){ while(cur<second.size()&&x+second[cur]>m){ cur++; } ans+=second.size()-cur; } cout<<ans; }

Compilation message (stderr)

bobek.cpp: In function 'int32_t main()':
bobek.cpp:40:18: 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]
   40 |         while(cur<second.size()&&x+second[cur]>m){
      |               ~~~^~~~~~~~~~~~~~
#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...