# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
241667 | anonymous | Ice Hockey World Championship (CEOI15_bobek) | C++14 | 1028 ms | 72380 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 <unordered_map>
#include <vector>
#include <algorithm>
#define LL long long
using namespace std;
LL N, M, Wt[45], Ways;
unordered_map <LL, LL> Freq;
vector <pair<LL,LL> > 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) {
Freq[wt]++;
}
}
for (auto p: Freq) {
Freq2.push_back(p);
}
sort(Freq2.begin(), Freq2.end());
for (int i=1; i<Freq2.size(); i++) {
Freq2[i].second += Freq2[i-1].second;
}
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,LL> {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... |