Submission #759224

#TimeUsernameProblemLanguageResultExecution timeMemory
759224sofija6Ice Hockey World Championship (CEOI15_bobek)C++14
100 / 100
214 ms20864 KiB
#include <bits/stdc++.h> #define ll long long #define MAXN 50 using namespace std; ll a[MAXN],m; vector<ll> v1,v2; void Solve(ll l,ll r,ll cur,ll pos,vector<ll> &v) { if (pos>r) { if (cur<=m) v.push_back(cur); return; } Solve(l,r,cur,pos+1,v); Solve(l,r,cur+a[pos],pos+1,v); } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); ll n,ans=0; cin >> n >> m; for (ll i=1;i<=n;i++) cin >> a[i]; Solve(1,n/2,0,1,v1); Solve(n/2+1,n,0,n/2+1,v2); sort(v1.begin(),v1.end()); sort(v2.begin(),v2.end()); for (auto i : v1) { auto it=upper_bound(v2.begin(),v2.end(),m-i); if (it==v2.begin()) continue; it--; ans+=it-v2.begin()+1; } cout << ans; 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...