Submission #542957

# Submission time Handle Problem Language Result Execution time Memory
542957 2022-03-28T14:31:01 Z prvocislo Ice Hockey World Championship (CEOI15_bobek) C++17
100 / 100
460 ms 8684 KB
#include <algorithm>
#include <iostream>
#include <string>
#include <chrono>
#include <vector>
#include <cmath>
#include <iomanip>
#include <queue>
#include <random>
#include <map>
#include <set>
typedef long long ll;
typedef long double ld;
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    ll s;
    cin >> n >> s;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    int n1 = n / 2, n2 = n - n / 2;
    vector<ll> s1;
    for (int i = 0; i < (1 << n1); i++)
    {
        ll sum = 0;
        for (int j = 0; j < n1; j++) if (i & (1 << j)) sum += a[j];
        s1.push_back(sum);
    }
    sort(s1.begin(), s1.end());
    ll ans = 0;
    for (int i = 0; i < (1 << n2); i++)
    {
        ll sum = 0;
        for (int j = 0; j < n2; j++) if (i & (1 << j)) sum += a[n1 + j];
        ans += upper_bound(s1.begin(), s1.end(), s - sum) - s1.begin();
    }
    cout << ans << "\n";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 224 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 324 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 244 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 972 KB Output is correct
2 Correct 96 ms 2496 KB Output is correct
3 Correct 460 ms 8684 KB Output is correct
4 Correct 86 ms 2512 KB Output is correct
5 Correct 14 ms 984 KB Output is correct
6 Correct 7 ms 708 KB Output is correct
7 Correct 13 ms 984 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 40 ms 1492 KB Output is correct
2 Correct 31 ms 984 KB Output is correct
3 Correct 181 ms 4520 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 7 ms 728 KB Output is correct
6 Correct 12 ms 984 KB Output is correct
7 Correct 12 ms 984 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 65 ms 1492 KB Output is correct
2 Correct 146 ms 2492 KB Output is correct
3 Correct 152 ms 2512 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 99 ms 2460 KB Output is correct
6 Correct 211 ms 8636 KB Output is correct
7 Correct 69 ms 2512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 307 ms 4592 KB Output is correct
2 Correct 28 ms 984 KB Output is correct
3 Correct 9 ms 712 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 7 ms 728 KB Output is correct
6 Correct 151 ms 4496 KB Output is correct
7 Correct 13 ms 984 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 30 ms 856 KB Output is correct
2 Correct 86 ms 2512 KB Output is correct
3 Correct 8 ms 728 KB Output is correct
4 Correct 8 ms 600 KB Output is correct
5 Correct 110 ms 2520 KB Output is correct
6 Correct 18 ms 984 KB Output is correct
7 Correct 216 ms 8628 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 355 ms 8624 KB Output is correct
2 Correct 31 ms 984 KB Output is correct
3 Correct 9 ms 728 KB Output is correct
4 Correct 453 ms 8636 KB Output is correct
5 Correct 127 ms 4556 KB Output is correct
6 Correct 13 ms 856 KB Output is correct
7 Correct 26 ms 1492 KB Output is correct