Submission #86815

#TimeUsernameProblemLanguageResultExecution timeMemory
86815igziIce Hockey World Championship (CEOI15_bobek)C++17
100 / 100
449 ms21296 KiB
#include <bits/stdc++.h> #define maxN 41 using namespace std; long long n,m,tmp,j,i,ans,a[maxN]; vector <long long> v,u; int main() { cin>>n>>m; for(i=0;i<n;i++) cin>>a[i]; v.push_back(0); for(i=0;i<n/2;i++){ tmp=v.size(); for(j=0;j<tmp;j++){ if(a[i]+v[j]>m) continue; v.push_back(a[i]+v[j]); } } u.push_back(0); for(i=n/2;i<n;i++){ tmp=u.size(); for(j=0;j<tmp;j++){ if(a[i]+u[j]>m) continue; u.push_back(a[i]+u[j]); } } sort(u.begin(),u.end()); for(i=0;i<v.size();i++){ ans+=lower_bound(u.begin(),u.end(),m-v[i]+1)-u.begin(); } cout<<ans<<endl; return 0; }

Compilation message (stderr)

bobek.cpp: In function 'int main()':
bobek.cpp:31:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(i=0;i<v.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...