Submission #3725700


Source Code Expand

#include <iostream>
#include <algorithm>
#define SUM_MAX 10000
using namespace std;

int main() {
    int n;
    cin >> n;
    int p[n];
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    bool dp[n + 1][SUM_MAX + 1];
    for (int i = 0; i <= n; i++) {
        fill(dp[i], dp[i] + SUM_MAX + 1, false);
    }
    dp[0][0] = true;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= SUM_MAX; j++) {
            if (dp[i][j]) {
                dp[i + 1][j] = true;
                dp[i + 1][j + p[i]] = true;
            }
        }
    }
    int ans = 0;
    for (int j = 0; j <= SUM_MAX; j++) {
        if (dp[n][j]) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Submission Info

Submission Time
Task A - コンテスト
User hi_watana
Language C++14 (GCC 5.4.1)
Score 2
Code Size 754 Byte
Status AC
Exec Time 3 ms
Memory 1280 KB

Judge Result

Set Name All
Score / Max Score 2 / 2
Status
AC × 5
Set Name Test Cases
All 00, 01, 02, 90, 91
Case Name Status Exec Time Memory
00 AC 1 ms 384 KB
01 AC 2 ms 768 KB
02 AC 3 ms 1280 KB
90 AC 1 ms 256 KB
91 AC 1 ms 384 KB