Submission #968443

#TimeUsernameProblemLanguageResultExecution timeMemory
968443vjudge1Ice Hockey World Championship (CEOI15_bobek)C++17
100 / 100
233 ms22732 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long ll n,m; ll pr[41]; vector<long long> a={0},b={0}; void solvea(ll curr,ll pos,ll end) { if (curr == m) { return; } for (int i=pos+1;i<end;i++) { if (curr+pr[i] <= m) { a.push_back(curr+pr[i]); solvea(curr+pr[i],i,end); } else { return; } } return; } void solveb(ll curr,ll pos,ll end) { if (curr == m) { return; } for (int i=pos+1;i<end;i++) { if (curr+pr[i] <= m) { b.push_back(curr+pr[i]); solveb(curr+pr[i],i,end); } else { return; } } return; } int main() { cin.tie(0)->sync_with_stdio(false); cin >> n >> m; for (int i=0;i<n;i++) { cin >> pr[i]; if (pr[i] > m) { i--; n--; } } sort(pr,pr+n); solvea(0,-1,n/2); solveb(0,n/2-1,n); sort(b.begin(),b.end()); ll cnt=0; n = a.size(); for (int i=0;i<n;i++) { cnt+=upper_bound(b.begin(),b.end(),m-a[i])-b.begin(); } cout << cnt; 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...