Submission #1121989

#TimeUsernameProblemLanguageResultExecution timeMemory
1121989Haciyev12Ice Hockey World Championship (CEOI15_bobek)C++14
100 / 100
404 ms8760 KiB
#include "bits/stdc++.h" #define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define ll long long #define fori for(int i=0;i<n;i++) #define forj for(int j=0;j<n;j++) #define pb push_back #define in insert #define F first #define S second #define endl '\n' using namespace std; int main(){ fast; ll n,x; cin>>n>>x; vector<ll>v; ll a[n]; for(int i=0;i<n;i++){ cin>>a[i]; } ll sum,mid=n/2,mid2=n-mid; ll ans=0; for(int i=0;i<(1<<mid);i++){ sum=0; for(int j=0;j<mid;j++){ if((i & (1<<j))!=0){ sum+=a[j]; } } v.pb(sum); //5 } sort(v.begin(),v.end()); for(int i=0;i<(1<<mid2);i++){ sum=0; for(int j=0;j<mid2;j++){ if((i & (1<<j))!=0){ sum+=a[j+mid];//10 } } auto q=upper_bound(v.begin(),v.end(),x-sum); ans+=q - v.begin(); } cout<<ans<<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...