Submission #97306


Source Code Expand

#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef vector<PII> VPII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define FOR( v, c ) for ( auto &v : c )
#define EACH( it, c ) for ( auto it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()
#define DRANGE( c, p ) (c).begin(), (c).begin() + p, (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

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

	int n;
	cin >> n;

	VI ps( n );
	FOR( p, ps )
	{
		cin >> p;
	}

	VVI dp( n + 1, VI( n * 100 + 1, 0 ) );
	dp[0][0] = 1;

	REP( i, 0, n )
	{
		REP( j, 0, dp[i].size() )
		{
			if ( j + ps[i] < dp[i].size() )
			{
				dp[ i + 1 ][ j + ps[i] ] |= dp[i][j];
			}
			dp[ i + 1 ][j] |= dp[i][j];
		}
	}

	cout << count( ALL( dp.back() ), 1 ) << endl;

	return 0;
}

Submission Info

Submission Time
Task A - コンテスト
User torus711
Language C++11 (GCC 4.8.1)
Score 2
Code Size 1737 Byte
Status AC
Exec Time 30 ms
Memory 4620 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 21 ms 772 KB
01 AC 22 ms 1796 KB
02 AC 30 ms 4620 KB
90 AC 19 ms 772 KB
91 AC 22 ms 772 KB