Submission #208569

# Submission time Handle Problem Language Result Execution time Memory
208569 2020-03-11T16:49:54 Z fr_klr Ice Hockey World Championship (CEOI15_bobek) C++14
100 / 100
244 ms 20944 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 376 KB Output is correct
2 Correct 4 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 256 KB Output is correct
7 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 256 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 0 ms 376 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
6 Correct 5 ms 380 KB Output is correct
7 Correct 5 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 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 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 2032 KB Output is correct
2 Correct 58 ms 5476 KB Output is correct
3 Correct 236 ms 20816 KB Output is correct
4 Correct 56 ms 5476 KB Output is correct
5 Correct 12 ms 1552 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 2032 KB Output is correct
3 Correct 86 ms 10588 KB Output is correct
4 Correct 5 ms 256 KB Output is correct
5 Correct 8 ms 1008 KB Output is correct
6 Correct 16 ms 1652 KB Output is correct
7 Correct 16 ms 1648 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 43 ms 3568 KB Output is correct
2 Correct 86 ms 6624 KB Output is correct
3 Correct 85 ms 6624 KB Output is correct
4 Correct 5 ms 256 KB Output is correct
5 Correct 43 ms 6624 KB Output is correct
6 Correct 205 ms 20816 KB Output is correct
7 Correct 82 ms 6624 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 176 ms 12756 KB Output is correct
2 Correct 24 ms 2032 KB Output is correct
3 Correct 10 ms 1012 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 9 ms 1008 KB Output is correct
6 Correct 179 ms 12756 KB Output is correct
7 Correct 15 ms 1648 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 2028 KB Output is correct
2 Correct 58 ms 5476 KB Output is correct
3 Correct 10 ms 1012 KB Output is correct
4 Correct 10 ms 1008 KB Output is correct
5 Correct 49 ms 6624 KB Output is correct
6 Correct 22 ms 2032 KB Output is correct
7 Correct 224 ms 20820 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 229 ms 20944 KB Output is correct
2 Correct 23 ms 2024 KB Output is correct
3 Correct 10 ms 1012 KB Output is correct
4 Correct 244 ms 20816 KB Output is correct
5 Correct 62 ms 10588 KB Output is correct
6 Correct 16 ms 1644 KB Output is correct
7 Correct 28 ms 2924 KB Output is correct