Submission #5497604


Source Code Expand

#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int dp[101][100010];

int main()
{
    int n;
    int a[10010];
    int ans = 0;
    bool num[100010] = {};

    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    dp[0][0] = 1;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= 10000; j++) {
            dp[i+1][j] |= dp[i][j];
            if (j >= a[i]) {
                dp[i+1][j] |= dp[i][j-a[i]];
            }
        }
    }

    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= 10000; j++) {
            if (dp[i][j]  && num[j] == 0) {
                ans++;
                num[j] = 1;
            }
        }
    }

    cout << ans << endl;
}

Submission Info

Submission Time
Task A - コンテスト
User wakimiko
Language C++14 (GCC 5.4.1)
Score 2
Code Size 834 Byte
Status AC
Exec Time 11 ms
Memory 37504 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 2 ms 2560 KB
01 AC 6 ms 18944 KB
02 AC 11 ms 37504 KB
90 AC 1 ms 512 KB
91 AC 2 ms 2560 KB