Submission #19679037


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //int:2*10**9
typedef long double ld;
typedef pair<ll,ll> P;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define vec2(name,i,j,k) vector<vector<ll>> name(i,vector<ll>(j,k))
#define vec3(name,i,j,k,l) vector<vector<vector<ll>>> name(i,vector<vector<ll>>(j,vector<ll>(k,l)))
#define pb push_back
#define MOD 1000000007 //998244353
#define PI 3.141592653
#define INF 100000000000000 //14
#define N 11000
//cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);

int main(){
  ll n; cin >> n;
  vector<ll> p(n);
  REP(i,n) cin >> p[i];
  vector<vector<ll>> scores(n,vector<ll>(N,0));
  scores[0][0]=1;
  scores[0][p[0]]=1;
  FOR(i,1,n-1) REP(j,N) {
    if (j==0) scores[i][j]=1;
    if (j==p[i]) scores[i][j]=1;
    if (scores[i-1][j]==1) scores[i][j]=1;
    if (scores[i-1][j-p[i]]==1) scores[i][j]=1;
  }
  ll ans = 0;
  REP(i,N) {
    REP(j,n) {
      if (scores[j][i]==1){
        // cout << j << " " << i << " " << endl;
        ans++;
        break;
      }
    }
  }
  cout << ans << endl;
}

Submission Info

Submission Time
Task A - コンテスト
User fu2tian2
Language C++ (GCC 9.2.1)
Score 2
Code Size 1192 Byte
Status AC
Exec Time 18 ms
Memory 11816 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 10 ms 4212 KB
01 AC 17 ms 7592 KB
02 AC 18 ms 11816 KB
90 AC 4 ms 3640 KB
91 AC 3 ms 4244 KB