Submission #46929

# Submission time Handle Problem Language Result Execution time Memory
46929 2018-04-24T22:43:37 Z alex99 Ice Hockey World Championship (CEOI15_bobek) C++14
100 / 100
371 ms 17568 KB
#include <iostream>
#include <algorithm>
using namespace std;
int N;
long long M;
long long A[(1 << 21) + 5], B[(1<< 21) + 5];
long long C[45];
void Read()
{
    cin >> N >> M;
    for(int i = 1; i <= N; i++)
    {
        cin >> C[i];
    }
}

void precalcAB()
{
    int lim = N / 2;
    for(int conf = 0; conf < (1 << lim); conf++)
    {
        long long sum = 0;
        for(int j = 0; j < lim; j++)
        {
            if((conf & (1 << j)) != 0)
                sum += C[j + 1];
        }
        A[conf] = sum;
    }
    for(int conf = 0; conf < (1 << (N - lim)); conf++)
    {
        long long sum = 0;
        for(int j = 0; j < N - lim; j++)
        {
            if((conf & (1 << j)) != 0)
                sum += C[j + lim + 1];
        }
        B[conf] = sum;
    }
    int x = (1 << lim);
    int y = ((1 << (N - lim)));
    sort(A, A + (1 << lim));
    sort(B , B + (1 << (N - lim)));
    int point = 0, point2 = y - 1;
    long long ans = 0;
    for(int i = 0; i < x; i++)
    {
        while(point2 >= 0 && B[point2] + A[i] > M)
            --point2;
        ans += point2 + 1;
    }
    cout << ans << '\n';
}
int main()
{
    Read();
    precalcAB();
    return 0;
}

Compilation message

bobek.cpp: In function 'void precalcAB()':
bobek.cpp:44:9: warning: unused variable 'point' [-Wunused-variable]
     int point = 0, point2 = y - 1;
         ^~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 360 KB Output is correct
2 Correct 2 ms 400 KB Output is correct
3 Correct 2 ms 644 KB Output is correct
4 Correct 2 ms 644 KB Output is correct
5 Correct 2 ms 644 KB Output is correct
6 Correct 2 ms 656 KB Output is correct
7 Correct 2 ms 656 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 656 KB Output is correct
2 Correct 2 ms 876 KB Output is correct
3 Correct 2 ms 876 KB Output is correct
4 Correct 2 ms 876 KB Output is correct
5 Correct 2 ms 876 KB Output is correct
6 Correct 2 ms 876 KB Output is correct
7 Correct 2 ms 876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 876 KB Output is correct
2 Correct 2 ms 876 KB Output is correct
3 Correct 2 ms 876 KB Output is correct
4 Correct 2 ms 876 KB Output is correct
5 Correct 2 ms 876 KB Output is correct
6 Correct 2 ms 876 KB Output is correct
7 Correct 2 ms 876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 29 ms 2356 KB Output is correct
2 Correct 86 ms 4920 KB Output is correct
3 Correct 371 ms 17364 KB Output is correct
4 Correct 92 ms 17364 KB Output is correct
5 Correct 16 ms 17364 KB Output is correct
6 Correct 10 ms 17364 KB Output is correct
7 Correct 20 ms 17364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 42 ms 17364 KB Output is correct
2 Correct 33 ms 17364 KB Output is correct
3 Correct 155 ms 17364 KB Output is correct
4 Correct 2 ms 17364 KB Output is correct
5 Correct 9 ms 17364 KB Output is correct
6 Correct 21 ms 17364 KB Output is correct
7 Correct 20 ms 17364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 63 ms 17364 KB Output is correct
2 Correct 135 ms 17364 KB Output is correct
3 Correct 135 ms 17364 KB Output is correct
4 Correct 2 ms 17364 KB Output is correct
5 Correct 88 ms 17364 KB Output is correct
6 Correct 319 ms 17428 KB Output is correct
7 Correct 129 ms 17428 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 282 ms 17428 KB Output is correct
2 Correct 37 ms 17428 KB Output is correct
3 Correct 11 ms 17428 KB Output is correct
4 Correct 2 ms 17428 KB Output is correct
5 Correct 9 ms 17428 KB Output is correct
6 Correct 263 ms 17428 KB Output is correct
7 Correct 21 ms 17428 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 33 ms 17428 KB Output is correct
2 Correct 85 ms 17428 KB Output is correct
3 Correct 11 ms 17428 KB Output is correct
4 Correct 11 ms 17428 KB Output is correct
5 Correct 95 ms 17428 KB Output is correct
6 Correct 35 ms 17428 KB Output is correct
7 Correct 363 ms 17476 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 359 ms 17476 KB Output is correct
2 Correct 32 ms 17476 KB Output is correct
3 Correct 12 ms 17476 KB Output is correct
4 Correct 369 ms 17568 KB Output is correct
5 Correct 121 ms 17568 KB Output is correct
6 Correct 24 ms 17568 KB Output is correct
7 Correct 41 ms 17568 KB Output is correct