Submission #1103941

#TimeUsernameProblemLanguageResultExecution timeMemory
1103941ezzzayIce Hockey World Championship (CEOI15_bobek)C++14
100 / 100
310 ms22952 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define ff first #define ss second #define pb push_back #define inf 1e18 const int N=45; int arr[N]; signed main(){ int n,x; cin>>n>>x; for(int i=1;i<=n;i++){ cin>>arr[i]; } vector<int>v,vc; for(int i=1;i<=n/2;i++){ v.pb(arr[i]); } for(int i=n/2+1;i<=n;i++){ vc.pb(arr[i]); } vector<int>mp1,mp2; int m=v.size(); for(int i=0;i<(1<<m);i++){ int s=0; for(int j=0;j<m;j++){ if(i & (1<<j)){ s+=v[j]; } } mp1.pb(s); } m=vc.size(); for(int i=0;i<(1<<m);i++){ int s=0; for(int j=0;j<m;j++){ if(i & (1<<j)){ s+=vc[j]; } } mp2.pb(s); } sort(mp2.begin(),mp2.end()); sort(mp1.begin(),mp1.end()); int cnt=0; for(auto a:mp1){ auto up=upper_bound(mp2.begin(),mp2.end(),x-a); cnt+=up-mp2.begin(); } cout<<cnt; }
#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...