# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1122404 | qrn | Ice Hockey World Championship (CEOI15_bobek) | C++14 | 440 ms | 20920 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define SPEED \
ios_base::sync_with_stdio(0); \
cin.tie(NULL); \
cout.tie(NULL);
#define pb push_back
#define endl "\n"
#define ALL(x) x.begin(), x.end()
#define intt long long
const intt mxN = 2e5 + 5;
void solve() {
intt n, k;
cin >> n >> k;
vector<intt> a(n);
for(int i = 0; i < n; i++) cin >> a[i];
vector<intt>l, r;
for(int i = 0; i < n / 2; i++) l.pb(a[i]);
for(int i = n / 2; i < n; i++) r.pb(a[i]);
vector<intt> asum, bsum;
for(intt msk = 0; msk < (1 << l.size()); msk++) {
intt sum = 0;
for(intt i = 0; i < 30; i++) {
if(msk & (1 << i)) {
sum += l[i];
}
}
asum.pb(sum);
}
for(intt msk = 0; msk < (1 << r.size()); msk++) {
intt sum = 0;
for(intt i = 0; i < 30; i++) {
if(msk & (1 << i)) {
sum += r[i];
}
}
bsum.pb(sum);
}
sort(bsum.begin(), bsum.end());
intt ans = 0;
for(int i = 0; i < asum.size(); i++) {
intt lft = k - asum[i];
ans += upper_bound(ALL(bsum), lft) - bsum.begin();
// cout << lft << " " << asum[i] << endl;
}
cout << ans << endl;
}
int main(){
SPEED;
int tst = 1, i = 1;
// cin >> tst;
while(tst--) {
solve();
}
return 0;
}
/*
*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |