Submission #386858

#TimeUsernameProblemLanguageResultExecution timeMemory
386858FatihSolakIce Hockey World Championship (CEOI15_bobek)C++17
100 / 100
550 ms8800 KiB
#include <bits/stdc++.h> #define N 45 using namespace std; long long arr[N]; vector<long long> v; void solve(){ long long n,m; cin >> n >> m; for(int i=0;i<n;i++)cin >> arr[i]; long long ans = 0; for(int i=0;i<(1<<(n/2));i++){ long long sum = 0; for(int j=0;j<(n/2);j++){ if(i & ( 1<<j)){ sum += arr[j]; } } v.push_back(sum); } sort(v.begin(),v.end()); int c = n/2; n -= n/2; for(int i=0;i<(1<<n);i++){ long long sum = 0; for(int j=0;j<n;j++){ if(i & ( 1<<j)){ sum += arr[c+j]; } } if(sum <=m){ ans += upper_bound(v.begin(),v.end(),m-sum) -v.begin(); } } cout << ans; } int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); #ifdef Local freopen("in.txt","r",stdin); freopen("out.txt","w",stdout); #endif int t=1; //cin>>t; while(t--){ solve(); } #ifdef Local cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds "; #endif }
#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...