Submission #967715

# Submission time Handle Problem Language Result Execution time Memory
967715 2024-04-22T16:55:59 Z njoop Ice Hockey World Championship (CEOI15_bobek) C++14
0 / 100
115 ms 26032 KB
#include <bits/stdc++.h>
#define ll long long
using namespace std;

ll n, m, arr[50], res1[1100010], res2[1100010], ans, ix;
vector<ll> dp1, dp2;

void find(int idx, ll mon, int cur, int lim, ll res[]) {
    if(cur > lim) return;
    if(mon + arr[cur] <= m) find(idx+pow(2, lim-cur), mon+arr[cur], cur+1, lim, res);
    find(idx, mon, cur+1, lim, res);
    if(cur == lim) res[idx] = mon;
}

int main() {
    cin.tie(0)->sync_with_stdio(0);
    cin >> n >> m;
    for(int i=1; i<=n; i++) {
        cin >> arr[i];
    }
    for(int i=0; i<1100010; i++) {
        res1[i] = -1;
        res2[i] = -1;
    }
    find(0, 0, 1, n/2, res1);
    find(0, 0, (n/2)+1, n, res2);
    for(int i=0; i<1100010; i++) {
        if(res1[i] != -1) dp1.push_back(res1[i]);
        if(res2[i] != -1) dp2.push_back(res2[i]);
    }
    sort(dp2.begin(), dp2.end());
    for(int i=0; i<dp1.size(); i++) {
        ix = lower_bound(dp2.begin(), dp2.end(), m-dp1[i]+1) - dp2.begin();
        ans += ix;
    }
    cout << ans;
    return 0;
}

Compilation message

bobek.cpp: In function 'int main()':
bobek.cpp:32:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |     for(int i=0; i<dp1.size(); i++) {
      |                  ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 17496 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 17500 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 17500 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 17496 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 18568 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 18896 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 19408 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 107 ms 26032 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 18644 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 115 ms 25920 KB Output isn't correct
2 Halted 0 ms 0 KB -