답안 #870257

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
870257 2023-11-07T11:12:36 Z vjudge1 Ice Hockey World Championship (CEOI15_bobek) C++17
70 / 100
1000 ms 300112 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";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 69256 KB Output is correct
2 Correct 15 ms 41308 KB Output is correct
3 Correct 12 ms 30300 KB Output is correct
4 Correct 21 ms 62276 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 24 ms 75612 KB Output is correct
7 Correct 19 ms 52056 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 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 4 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 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 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 5724 KB Output is correct
2 Correct 66 ms 179600 KB Output is correct
3 Correct 111 ms 300112 KB Output is correct
4 Correct 61 ms 173520 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 21 ms 43356 KB Output is correct
7 Correct 48 ms 133468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 10328 KB Output is correct
2 Correct 31 ms 68228 KB Output is correct
3 Correct 2 ms 4444 KB Output is correct
4 Correct 10 ms 22108 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 74 ms 231788 KB Output is correct
7 Correct 3 ms 4696 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 56 ms 152408 KB Output is correct
2 Correct 38 ms 89172 KB Output is correct
3 Correct 36 ms 84560 KB Output is correct
4 Correct 6 ms 11864 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 58 ms 159136 KB Output is correct
7 Correct 55 ms 143452 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1058 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1060 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1070 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -