Submission #870256

# Submission time Handle Problem Language Result Execution time Memory
870256 2023-11-07T11:12:21 Z GordonRemzi007 Ice Hockey World Championship (CEOI15_bobek) C++17
70 / 100
1000 ms 300000 KB
#include <iostream>
#include <vector>
#define int long long

using namespace std;

int n, m, res = 0;
vector<int> a;
void dfs(int i, int sum) {
    if(i == n) {
        res++;
        return;
    }
    if(sum+a[i] <= m) dfs(i+1, sum+a[i]);
    dfs(i+1, sum);
}

signed main() {
    cin >> n >> m;
    a = vector<int>(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    if(m > 1e6) {
        dfs(0, 0);
    } else {
        vector<vector<int>> dp(n+1, vector<int>(m+1));
        dp[0][0] = 1;
        for(int i = 1; i <= n; i++) {
            for(int j = 0; j <= m; j++) {
                dp[i][j] = dp[i-1][j]+(j>=a[i-1] ? dp[i-1][j-a[i-1]] : 0);
            //cout << dp[i][j] << " ";
            }
        //cout << "\n";
        }
        for(int i = 0; i <= m; i++) res+=dp[n][i];
    }
    cout << res << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 69212 KB Output is correct
2 Correct 15 ms 41604 KB Output is correct
3 Correct 16 ms 30288 KB Output is correct
4 Correct 22 ms 62044 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 25 ms 75608 KB Output is correct
7 Correct 20 ms 52060 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 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 344 KB Output is correct
6 Correct 4 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 348 KB Output is correct
2 Correct 1 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 1 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 5724 KB Output is correct
2 Correct 71 ms 179704 KB Output is correct
3 Correct 109 ms 300000 KB Output is correct
4 Correct 61 ms 173392 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 19 ms 43356 KB Output is correct
7 Correct 50 ms 133460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 10328 KB Output is correct
2 Correct 31 ms 68440 KB Output is correct
3 Correct 2 ms 4440 KB Output is correct
4 Correct 9 ms 22104 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 80 ms 231788 KB Output is correct
7 Correct 3 ms 4700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 55 ms 152408 KB Output is correct
2 Correct 39 ms 89180 KB Output is correct
3 Correct 37 ms 84656 KB Output is correct
4 Correct 6 ms 11868 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 57 ms 159212 KB Output is correct
7 Correct 59 ms 143184 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1065 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1043 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1045 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -