Submission #1121522

#TimeUsernameProblemLanguageResultExecution timeMemory
1121522vjudge1Ice Hockey World Championship (CEOI15_bobek)C++17
10 / 100
197 ms8636 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); /*if(sum <= x){ int q = upper_bound(v.begin(),v.end(),sum)-lower_bound(v.begin(),v.end(),sum); ans += q; }*/ } 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]; } } int q; /* if(sum <= x){ q = upper_bound(v.begin(),v.end(),sum)-lower_bound(v.begin(),v.end(),sum); ans += q; }*/ q=upper_bound(v.begin(),v.end(),x-sum)-lower_bound(v.begin(),v.end(),x-sum); ans+=1; } cout<<ans<<endl; }

Compilation message (stderr)

bobek.cpp: In function 'int main()':
bobek.cpp:45:13: warning: variable 'q' set but not used [-Wunused-but-set-variable]
   45 |         int q;
      |             ^
#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...