Submission #55550

# Submission time Handle Problem Language Result Execution time Memory
55550 2018-07-07T22:07:26 Z zelinski Ice Hockey World Championship (CEOI15_bobek) C++11
10 / 100
167 ms 33696 KB
#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+1)/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

bobek.cpp: In function 'int main()':
bobek.cpp:37:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %lld",&P,&K);
     ~~~~~^~~~~~~~~~~~~~~~~
bobek.cpp:38:36: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(i = 1; i <= P/2; ++i) scanf("%lld",&x[++N]);
                               ~~~~~^~~~~~~~~~~~~~~~
bobek.cpp:42:40: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(i = (P+1)/2; i <= P; ++i) scanf("%lld",&x[++M]);
                                   ~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 508 KB Output is correct
2 Correct 2 ms 564 KB Output is correct
3 Correct 2 ms 564 KB Output is correct
4 Correct 2 ms 564 KB Output is correct
5 Incorrect 2 ms 564 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 588 KB Output is correct
2 Incorrect 2 ms 592 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 636 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 17 ms 2176 KB Output is correct
2 Incorrect 79 ms 6972 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 33 ms 6972 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 39 ms 6972 KB Output is correct
2 Correct 84 ms 7004 KB Output is correct
3 Correct 80 ms 7008 KB Output is correct
4 Incorrect 3 ms 7008 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 167 ms 13156 KB Output is correct
2 Correct 21 ms 13156 KB Output is correct
3 Incorrect 10 ms 13156 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 18 ms 13156 KB Output is correct
2 Incorrect 74 ms 13156 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 41 ms 33696 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -