Submission #996243

# Submission time Handle Problem Language Result Execution time Memory
996243 2024-06-10T09:10:52 Z vjudge1 Ice Hockey World Championship (CEOI15_bobek) C++17
100 / 100
191 ms 22732 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define lwb lower_bound
#define upb upper_bound

#define TASKNAME "NAME"

void init()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ///freopen(TASKNAME".INP","r",stdin); freopen(TASKNAME".OUT","w",stdout);
}

const int SZ = 1e6+5;
const ll INF = INT_MAX / 2, MOD = 1e9+7, INFLL = 2e18;
const double epsilon = 1e-3;

int n;
ll m, a[SZ];
vector<ll> s1, s2;

void recur1(int pos, ll sum)
{
    if(pos == n/2+1)
    {
        s1.pb(sum);
        return;
    }
    recur1(pos+1, sum);
    recur1(pos+1, sum + a[pos]);
}

void recur2(int pos, ll sum)
{
    if(pos == n+1)
    {
        s2.pb(sum);
        return;
    }
    recur2(pos+1, sum);
    recur2(pos+1, sum + a[pos]);
}

ll res = 0;

int main()
{
    init();
    cin >> n >> m;
    for(int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    recur1(1, 0);
    recur2(n/2 + 1, 0);
    sort(all(s1));
    sort(all(s2));
    for(ll x : s1)
    {
        ll y = m - x;
        int pos = upper_bound(all(s2), y) - s2.begin();
        res += max(0LL, 1LL*pos);
    }
    cout << res;
}

# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 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 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 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 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 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 0 ms 348 KB Output is correct
6 Correct 0 ms 464 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 2144 KB Output is correct
2 Correct 46 ms 5396 KB Output is correct
3 Correct 185 ms 20940 KB Output is correct
4 Correct 43 ms 6612 KB Output is correct
5 Correct 7 ms 1756 KB Output is correct
6 Correct 5 ms 1116 KB Output is correct
7 Correct 9 ms 1616 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 3032 KB Output is correct
2 Correct 15 ms 2144 KB Output is correct
3 Correct 67 ms 10948 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 3 ms 1116 KB Output is correct
6 Correct 9 ms 1648 KB Output is correct
7 Correct 10 ms 1752 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 32 ms 3676 KB Output is correct
2 Correct 65 ms 8536 KB Output is correct
3 Correct 68 ms 8280 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 30 ms 8268 KB Output is correct
6 Correct 146 ms 20936 KB Output is correct
7 Correct 57 ms 8024 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 138 ms 12792 KB Output is correct
2 Correct 15 ms 2140 KB Output is correct
3 Correct 6 ms 1116 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 3 ms 1116 KB Output is correct
6 Correct 124 ms 12924 KB Output is correct
7 Correct 9 ms 1756 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 2128 KB Output is correct
2 Correct 45 ms 5608 KB Output is correct
3 Correct 5 ms 1116 KB Output is correct
4 Correct 5 ms 1072 KB Output is correct
5 Correct 34 ms 8536 KB Output is correct
6 Correct 14 ms 2140 KB Output is correct
7 Correct 172 ms 22732 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 180 ms 20940 KB Output is correct
2 Correct 15 ms 2144 KB Output is correct
3 Correct 5 ms 1116 KB Output is correct
4 Correct 191 ms 22732 KB Output is correct
5 Correct 45 ms 12492 KB Output is correct
6 Correct 9 ms 1756 KB Output is correct
7 Correct 19 ms 2900 KB Output is correct