Submission #759208

#TimeUsernameProblemLanguageResultExecution timeMemory
759208sofija6Ice Hockey World Championship (CEOI15_bobek)C++14
50 / 100
1085 ms156516 KiB
#include <bits/stdc++.h> #define ll long long #define MAXN 50 using namespace std; ll a[MAXN]; set<ll> s1,s2; map<ll,ll> cnt1,cnt2; void Solve(ll l,ll r,ll cur,ll pos,set<ll> &s,map<ll,ll> &cnt) { if (pos>r) { s.insert(cur); cnt[cur]++; return; } Solve(l,r,cur,pos+1,s,cnt); Solve(l,r,cur+a[pos],pos+1,s,cnt); } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); ll n,m,ans=0; cin >> n >> m; for (ll i=1;i<=n;i++) cin >> a[i]; Solve(1,n/2,0,1,s1,cnt1); Solve(n/2+1,n,0,n/2+1,s2,cnt2); ll cur=0; for (auto i : cnt2) { cur+=i.second; cnt2[i.first]=cur; } for (auto i : s1) { auto it=s2.lower_bound(m-i); if ((*it)!=m-i) { if (it==s2.begin()) continue; it--; } ans+=cnt1[i]*cnt2[*it]; } 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...