# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
533296 | ddy888 | Ice Hockey World Championship (CEOI15_bobek) | C++17 | 509 ms | 16708 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 ll long long
#define pb push_back
#define mp make_pair
typedef pair<int,int> pi;
int N;
ll M,A1[1<<20],A2[1<<20],v1[1<<20],v2[1<<20];
int main() {
scanf("%d%lld",&N,&M);
int t = N/2;
N -= t;
for (int i = 0; i < N; i++) cin >> A1[i];
for (int i = 0; i < t; i++) cin >> A2[i];
for (int i = 0; i < (1<<N); i++) {
for (int j = 0; j < N; j++) {
if (i&(1<<j)) v1[i] += A1[j];
}
}
for (int i = 0; i < (1<<t); i++) {
for (int j = 0; j < t; j++) {
if (i&(1<<j)) v2[i] += A2[j];
}
}
sort(v2,v2+(1<<t));
ll ans = 0;
for (int i = 0; i < (1<<N); i++) {
ll tmp = M- v1[i];
ans += upper_bound(v2,v2+(1<<t),tmp)-v2;
}
printf("%lld",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... |