Submission #6419786


Source Code Expand

#include <bits/stdc++.h>
#define INF LLONG_MAX
#define Int long long
#define rep(i,n) for(Int i=0; i<n; ++i)
using namespace std;
 
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmas(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  Int N; cin >> N;
  vector<Int> p(N);
  vector<vector<bool>> dp(N+1, vector<bool>(N*100+1, false));
  rep(i,N) cin >> p[i];
  dp[0][0] = true;
  rep(i,N) {
    rep(j, N*100+1) {
      if( dp[i][j] ) dp[i+1][j] = true;
      if( j>=p[i] && dp[i][j-p[i]]) dp[i+1][j] = true;
    }
  }
  Int cnt = 0;
  rep(i, N*100+1) if(dp[N][i]) cnt++;
  cout << cnt << endl;
}

Submission Info

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