# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
28747 | rondojim | Ice Hockey World Championship (CEOI15_bobek) | C++14 | 486 ms | 13548 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 <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
const int MAXN = 40;
typedef long long ll;
ll N, K, A[MAXN], result;
int main(){
#ifdef DEBUG
freopen("input.txt", "r", stdin);
#endif
scanf("%lld %lld", &N, &K);
for(int i=0; i<N; ++i) scanf("%lld", &A[i]);
int middle = N / 2, remain = N - N / 2;
vector<ll> sums;
for(int bitm=0; bitm<(1<<middle); ++bitm){
ll sum = 0;
for(int i=0; i<middle; ++i) if(bitm & (1<<i)) sum += A[i];
sums.push_back(sum);
}
sort(sums.begin(), sums.end());
for(int bitm=0; bitm<(1<<remain); ++bitm){
ll sum = 0;
for(int i=0; i<remain; ++i) if(bitm & (1<<i)) sum += A[middle + i];
int lo = 0, hi = sums.size() - 1, res = -1, mid;
while(lo <= hi){
mid = (lo + hi)>>1;
if(sums[mid] + sum < K) lo = mid + 1;
else res = mid, hi = mid - 1;
}
if(res != -1) result += sums.size() - res;
}
printf("%lld\n", result);
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... |