# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
55551 | zelinski | Ice Hockey World Championship (CEOI15_bobek) | C++11 | 236 ms | 17400 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 x first
#define y second
#define MaxN 20
#define MaxG 1048576
#define int64 long long
using namespace std;
int64 sum[2][MaxG+1];
int64 v[2][MaxN+1];
int64 x[MaxN+1];
int64 temp,K;
int N,M,X,Y,P;
int C[2];
void Solve(int l, int N)
{
if(!N) sum[l][ ++C[l] ] = temp;
else{
temp = temp + v[l][N];
Solve(l, N-1);
temp = temp - v[l][N];
Solve(l, N-1);
}
}
int main(){
/*
freopen("file.in","r",stdin);
freopen("file.out","w",stdout);
*/
int i,j;
int64 res = 0;
scanf("%d %lld",&P,&K);
for(i = 1; i <= P/2; ++i) scanf("%lld",&x[++N]);
sort(x+1, x+N+1);
for(i = 1; i <= N; ++i) v[0][i] = x[i];
for(i = (P+2)/2; i <= P; ++i) scanf("%lld",&x[++M]);
sort(x+1, x+M+1);
for(i = 1; i <= M; ++i) v[1][i] = x[i];
Solve(0, N);
Solve(1, M);
X = C[0]; Y = C[1];
sort(sum[0]+1, sum[0]+X+1);
sort(sum[1]+1, sum[1]+Y+1);
for(i = 1, j = Y; i <= X; ++i)
{
while(sum[0][i] + sum[1][j] > K && j) --j;
res = res + j;
}
printf("%lld\n",res);
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... |