Submission #5433894


Source Code Expand

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i) sort((i).begin(),(i).end(), greater<int>());
#define YES(i) cout << ((i) ? "Yes" : "No") << endl;
constexpr auto INF = 1000000000;
constexpr auto LLINF = 9223372036854775807;
constexpr auto mod = 1000000007;

bool dp[101][10001] = {};

int main() {

	int n;
	cin >> n;
	VI p(n);
	FOR(i, n)cin >> p[i];

	SORT(p);
	int m = n * p[n - 1];
	dp[0][0] = 1;
	
	FOR(i, n)eFOR(j, m) {
		if (p[i] <= j)dp[i + 1][j] |= dp[i][j - p[i]];
		dp[i + 1][j] |= dp[i][j];
	}

	int ans = 0;
	eFOR(i, m)if (dp[n][i])ans++;
	cout << ans << endl;

	return 0;
}

Submission Info

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