# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
879432 | KN200711 | Ice Hockey World Championship (CEOI15_bobek) | C++14 | 417 ms | 21664 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>
# define ll long long
using namespace std;
int main() {
int N;
ll K;
scanf("%d %lld", &N, &K);
vector<int> arr(N);
for(int i=0;i<N;i++) {
scanf("%d", &arr[i]);
}
vector<ll> A, B;
A.clear();
B.clear();
int G = N / 2;
for(int i=0;i<(1 << G);i++) {
ll as = 0ll;
for(int k=0;k<G;k++) {
if(i&(1 << k)) as += arr[k];
}
A.push_back(as);
}
for(int i=0;i<(1 << (N - G));i++) {
ll as = 0ll;
for(int k=0;k<(N - G);k++) {
if(i&(1 << k)) as += arr[k + G];
}
B.push_back(as);
}
sort(B.begin(), B.end());
ll ans = 0ll;
for(int i=0;i<A.size();i++) {
ans += upper_bound(B.begin(), B.end(), K - A[i]) - B.begin();
}
printf("%lld\n", ans);
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... |