Submission #968440

#TimeUsernameProblemLanguageResultExecution timeMemory
968440vjudge1Ice Hockey World Championship (CEOI15_bobek)C++17
0 / 100
174 ms31724 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long ll n,m; ll pr[41]; vector<int> 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); for (auto i : a) { cout << i << ' '; } cout <<'\n'; for (auto i : b) { cout << i << ' '; } cout <<'\n'; 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...