Submission #968442

# Submission time Handle Problem Language Result Execution time Memory
968442 2024-04-23T12:30:08 Z vjudge1 Ice Hockey World Championship (CEOI15_bobek) C++17
50 / 100
206 ms 12496 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll n,m;
ll pr[41];
vector<int> a={0},b={0};
void solvea(ll curr,ll pos,ll end) {
    if (curr == m) {
        return;
    }
    for (int i=pos+1;i<end;i++) {
        if (curr+pr[i] <= m) {
            a.push_back(curr+pr[i]);
            solvea(curr+pr[i],i,end);
        } else {
            return;
        }
    }
    return;
}
void solveb(ll curr,ll pos,ll end) {
    if (curr == m) {
        return;
    }
    for (int i=pos+1;i<end;i++) {
        if (curr+pr[i] <= m) {
            b.push_back(curr+pr[i]);
            solveb(curr+pr[i],i,end);
        } else {
            return;
        }
    }
    return;
}
int main() {
    cin.tie(0)->sync_with_stdio(false);
    cin >> n >> m;
    for (int i=0;i<n;i++) {
        cin >> pr[i];
        if (pr[i] > m) {
            i--;
            n--;
        }
    }
    sort(pr,pr+n);
    solvea(0,-1,n/2);
    solveb(0,n/2-1,n);
    sort(b.begin(),b.end());
    ll cnt=0;
    n = a.size();
    for (int i=0;i<n;i++) {
        cnt+=upper_bound(b.begin(),b.end(),m-a[i])-b.begin();
    }
    cout << cnt;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 15 ms 1368 KB Output is correct
2 Correct 45 ms 3032 KB Output is correct
3 Correct 206 ms 11472 KB Output is correct
4 Correct 44 ms 3028 KB Output is correct
5 Correct 5 ms 988 KB Output is correct
6 Correct 3 ms 728 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 23 ms 1612 KB Output is correct
2 Correct 15 ms 1372 KB Output is correct
3 Correct 82 ms 5440 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 2 ms 760 KB Output is correct
6 Correct 6 ms 1112 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 30 ms 1888 KB Output is correct
2 Correct 68 ms 3676 KB Output is correct
3 Correct 66 ms 3676 KB Output is correct
4 Correct 1 ms 504 KB Output is correct
5 Correct 29 ms 3672 KB Output is correct
6 Correct 99 ms 12496 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 98 ms 7980 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 1368 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 109 ms 12364 KB Output isn't correct
2 Halted 0 ms 0 KB -