Submission #941831

#TimeUsernameProblemLanguageResultExecution timeMemory
941831maxFedorchukIce Hockey World Championship (CEOI15_bobek)C++17
40 / 100
1099 ms456 KiB
#include <bits/stdc++.h> using namespace std; const long long MX=44; long long pr[MX],st2[MX],a[MX]; long long cnt(long long n,long long k) { if(n==0 || k<a[1]) { return 1; } if(pr[n]<=k) { return st2[n]; } long long o=0; if(a[n]<=k) { o=cnt(n-1,k-a[n]); } return (o+cnt(n-1,k)); } int main() { cin.tie(0); ios_base::sync_with_stdio(0); long long n,k; cin>>n>>k; for(long long i=1;i<=n;i++) { cin>>a[i]; } sort(a+1,a+1+n); st2[0]=1; for(long long i=1;i<=n;i++) { pr[i]=pr[i-1]+a[i]; st2[i]=(st2[i-1]*2); } cout<<cnt(n,k)<<"\n"; return 0; }
#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...