Submission #380375

#TimeUsernameProblemLanguageResultExecution timeMemory
380375ritul_kr_singhIce Hockey World Championship (CEOI15_bobek)C++17
100 / 100
503 ms29020 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define sp << ' ' << #define nl << '\n' vector<int> create(vector<int> a, bool sorted){ int n = a.size(); const int LIM = 1<<n; int sum[LIM] = {0}; vector<int> res = {0}; for(int i=1; i<LIM; ++i){ int last = 0; for(int j=0; j<n; ++j) if((1<<j)&i) last = j; sum[i] = sum[i^(1<<last)] + a[last]; res.push_back(sum[i]); } if(sorted) sort(res.begin(), res.end()); return res; } signed main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int n, m; cin >> n >> m; vector<int> a(n/2), b(n-n/2); for(int i=0; i<n/2; ++i) cin >> a[i]; for(int i=n/2; i<n; ++i) cin >> b[i-n/2]; vector<int> c = create(a, false), d = create(b, true); int ans = 0; for(int i : c){ if(i<=m){ auto f = upper_bound(d.begin(), d.end(), m-i); ans += f-d.begin(); } } cout << ans; }
#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...