Submission #448696

#TimeUsernameProblemLanguageResultExecution timeMemory
448696osmanallazovIce Hockey World Championship (CEOI15_bobek)C++14
100 / 100
485 ms8660 KiB
#include <iostream> #include <vector> #include <algorithm> using namespace std; typedef long long ll; int main() { int n; cin>>n; ll k; cin>>k; vector<ll>v; int p=n/2; int p1=n-p; vector<ll>vc; for(int i=0;i<n;i++) { ll a; cin>>a; v.push_back(a); } ll res=0; for(int i=1;i<(1<<p);i++) { ll s=0; for(int j=0;j<p;j++) { if(i&(1<<j)) { s+=v[j]; } } if(s<=k) { vc.push_back(s); res++; } } sort(vc.begin(),vc.end()); for(int i=1;i<(1<<p1);i++) { ll s=0; for(int j=0;j<p1;j++) { if(i&(1<<j)) { s+=v[j+p]; } } if(s<=k) { res++; res+=(upper_bound(vc.begin(),vc.end(),k-s)-vc.begin()); } } res++; cout<<res<<endl; }
#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...