Submission #759221

#TimeUsernameProblemLanguageResultExecution timeMemory
759221sofija6Ice Hockey World Championship (CEOI15_bobek)C++14
100 / 100
220 ms20852 KiB
#include <bits/stdc++.h> #define ll long long #define MAXN 50 using namespace std; ll a[MAXN],m,l,r; vector<ll> v1,v2; void Solve_1(ll cur,ll pos) { if (pos>r) { if (cur>m) return; v1.push_back(cur); return; } Solve_1(cur,pos+1); Solve_1(cur+a[pos],pos+1); } void Solve_2(ll cur,ll pos) { if (pos>r) { if (cur>m) return; v2.push_back(cur); return; } Solve_2(cur,pos+1); Solve_2(cur+a[pos],pos+1); } 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]; l=1; r=n/2; Solve_1(0,1); l=n/2+1; r=n; Solve_2(0,n/2+1); 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...