# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
241669 | anonymous | Ice Hockey World Championship (CEOI15_bobek) | C++14 | 681 ms | 25156 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 <iostream>
#include <vector>
#include <algorithm>
#define LL long long
using namespace std;
LL N, M, Wt[45], Ways;
vector <LL> List;
vector <pair<LL,int> > Freq2;
int main() {
//freopen("bobekin.txt","r",stdin);
scanf("%lld %lld",&N,&M);
for (int i=0; i < N; i++) {
scanf("%lld", &Wt[i]);
}
for (int i=0; i < 1<<(N/2); i++) {
LL wt = 0;
for (int j=0; j < N/2; j++) {
if (i & (1<<j)) {wt += Wt[j];}
}
if (wt <= M) {
List.push_back(wt);
}
}
sort(List.begin(), List.end());
for (int i=0; i<List.size(); i++) {
if (i + 1 == List.size() || List[i] != List[i+1]) {
Freq2.push_back({List[i], i+1});
}
}
for (int i=0; i < 1<< (N - N/2); i++) {
LL wt = 0;
for (int j=0; j < N - N/2; j++) {
if (i & (1<<j)) {wt += Wt[j + N/2];}
}
if (wt <= M) {
auto it = upper_bound(Freq2.begin(), Freq2.end(), pair <LL,int> {M - wt + 1, 0});
Ways += Freq2[it - Freq2.begin() - 1].second;
}
}
printf("%lld",Ways);
}
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... |