Submission #19427136


Source Code Expand

Copy
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
// #include <atcoder/all>
// using namespace atcoder;
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
using vll = vector<ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
ostream& operator<<(ostream& os, lpair& h){ os << "(" << h.first << ", " << h.second << ")"; return os;}
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

void solve(){
    ll N;
    cin >> N;
    vll p(N);
    rep(i,0,N) cin >> p[i];
    vector<bool> dp(10001,false);
    dp[0] = true;
    rep(i,0,N){
        rrep(j,10000,p[i]){
            dp[j] = dp[j-p[i]] | dp[j];
        }
    }
    ll ans = 0;
    rep(i,0,10001) ans += dp[i];
    print(ans);
    

}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
}

Submission Info

Submission Time
Task A - コンテスト
User yuji9511
Language C++ (GCC 9.2.1)
Score 2
Code Size 1063 Byte
Status AC
Exec Time 9 ms
Memory 3604 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 9 ms 3544 KB
01 AC 5 ms 3496 KB
02 AC 8 ms 3540 KB
90 AC 2 ms 3544 KB
91 AC 3 ms 3604 KB