Submission #5431376
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}
const int INFTY=100;
int n;
int mx=0;
vector<int> a(INFTY);
int solve(int n,int mx){
int cnt=0;
vector<vector<bool>> dp(n+1,vector<bool>(mx+1,false));
dp[0][0]=true;
rep(i,n) rep(j,mx+1){
dp[i+1][j] = dp[i][j];
if(a[i]<=j) dp[i+1][j] = dp[i][j-a[i]];
}
rep(j,mx+1) if(dp[n][j]) cnt++;
return cnt;
}
int main() {
cin >> n;
rep(i,n){
cin >> a[i];
mx+=a[i];
}
cout << solve(n,mx) << endl;
}
Submission Info
Submission Time |
|
Task |
A - コンテスト |
User |
potagashi |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
1246 Byte |
Status |
WA |
Exec Time |
3 ms |
Memory |
384 KB |
Judge Result
Set Name |
All |
Score / Max Score |
0 / 2 |
Status |
|
Set Name |
Test Cases |
All |
00, 01, 02, 90, 91 |
Case Name |
Status |
Exec Time |
Memory |
00 |
WA |
1 ms |
256 KB |
01 |
WA |
2 ms |
256 KB |
02 |
WA |
3 ms |
384 KB |
90 |
AC |
1 ms |
256 KB |
91 |
AC |
1 ms |
256 KB |