Submission #208567

# Submission time Handle Problem Language Result Execution time Memory
208567 2020-03-11T16:48:47 Z fr_klr Ice Hockey World Championship (CEOI15_bobek) C++14
100 / 100
247 ms 20896 KB
//You can't fill the hole inside you with money, drugs and cars
#include<bits/stdc++.h>
using namespace std;

long long n, m;
vector<long long> v, a, b;

void create(int st, int en, vector<long long> &w){
    int sz = en - st;
    w.push_back(0);
    for(int mask = 1; mask < (1 << sz); mask++)
        w.push_back(w[mask - (mask & -mask)] + v[st + __builtin_ctz(mask)]);

}

long long inp(){
    long long A;
    cin >> A;
    return A;
}

void input(){
    cin >> n >> m;
    for(int i = 0; i < n; i++)
        v.push_back(inp());
}

long long matches(int p1 = 0, int p2 = b.size() - 1, long long ans = 0){
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());

    for(auto A : a){
        while(p2 >= 0 and A + b[p2] > m)
            p2--;
        ans += (p2 + 1);
        if(p2 < 0)
            break;
    }
    return ans;
}

long long solve(){
    int mid = n / 2;
    create(0, mid, a);
    create(mid, n, b);

    return matches();
}

int main(){
    input();
    cout << solve();
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 380 KB Output is correct
4 Correct 5 ms 256 KB Output is correct
5 Correct 5 ms 380 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Correct 4 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 5 ms 256 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 5 ms 256 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 2028 KB Output is correct
2 Correct 59 ms 5476 KB Output is correct
3 Correct 247 ms 20896 KB Output is correct
4 Correct 59 ms 5476 KB Output is correct
5 Correct 12 ms 1648 KB Output is correct
6 Correct 10 ms 1012 KB Output is correct
7 Correct 16 ms 1648 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 2920 KB Output is correct
2 Correct 23 ms 2028 KB Output is correct
3 Correct 91 ms 10588 KB Output is correct
4 Correct 5 ms 256 KB Output is correct
5 Correct 8 ms 1012 KB Output is correct
6 Correct 16 ms 1648 KB Output is correct
7 Correct 16 ms 1648 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 42 ms 3564 KB Output is correct
2 Correct 86 ms 6624 KB Output is correct
3 Correct 89 ms 6624 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 41 ms 6752 KB Output is correct
6 Correct 203 ms 20796 KB Output is correct
7 Correct 83 ms 6624 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 176 ms 12756 KB Output is correct
2 Correct 26 ms 2032 KB Output is correct
3 Correct 11 ms 1012 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 8 ms 1012 KB Output is correct
6 Correct 171 ms 12756 KB Output is correct
7 Correct 16 ms 1648 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 23 ms 2028 KB Output is correct
2 Correct 58 ms 5476 KB Output is correct
3 Correct 13 ms 1012 KB Output is correct
4 Correct 13 ms 1012 KB Output is correct
5 Correct 48 ms 6624 KB Output is correct
6 Correct 22 ms 2032 KB Output is correct
7 Correct 219 ms 20816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 247 ms 20816 KB Output is correct
2 Correct 23 ms 2028 KB Output is correct
3 Correct 11 ms 1012 KB Output is correct
4 Correct 245 ms 20820 KB Output is correct
5 Correct 61 ms 10588 KB Output is correct
6 Correct 17 ms 1644 KB Output is correct
7 Correct 28 ms 2924 KB Output is correct