Submission #2015206


Source Code Expand

#include <cstdio>
#define repd(i,a) for(int i=(a);i>=0;--i)
#define rep(i,a) for(int i=0;i<(a);++i)

constexpr int MAX_N = 100;

int N;
int p[MAX_N], S = 0;
bool dp[10001];

int main()
{
  scanf( "%d", &N );
  rep( i, N )
    scanf( "%d", p+i ), S += p[i];

  dp[0] = true;

  rep( i, N ) repd( j, S ) if( dp[j] )
      dp[j+p[i]] = true;

  int ans = 0;
  rep( i, S+1 ) if( dp[i] )
    ++ans;

  printf( "%d\n", ans );

  return 0;
}

Submission Info

Submission Time
Task A - コンテスト
User As_sqr
Language C++14 (GCC 5.4.1)
Score 2
Code Size 462 Byte
Status AC
Exec Time 1 ms
Memory 128 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:13:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf( "%d", &N );
                    ^
./Main.cpp:15:34: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf( "%d", p+i ), S += p[i];
                                  ^

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 128 KB
01 AC 1 ms 128 KB
02 AC 1 ms 128 KB
90 AC 1 ms 128 KB
91 AC 1 ms 128 KB