Submission #5630289


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

int main(){
    int n;
    cin>>n;
    int p[n];
    rep(i,n) cin>>p[i];
    bool dp[10010];
    rep(i,10010)dp[i]=false;
    dp[0]=true;
    rep(i,n){
        for(int j=10009;j>=p[i];--j){
            if(dp[j-p[i]])dp[j]=true;
        }
    }
    int ans=0;
    rep(i,10010)if(dp[i])++ans;
    cout<<ans<<endl;
}

Submission Info

Submission Time
Task A - コンテスト
User db7
Language C++14 (GCC 5.4.1)
Score 2
Code Size 804 Byte
Status AC
Exec Time 2 ms
Memory 256 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 256 KB
01 AC 2 ms 256 KB
02 AC 2 ms 256 KB
90 AC 1 ms 256 KB
91 AC 1 ms 256 KB