Submission #5431321
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;
int cnt=0;
vector<int> a(INFTY);
int solve(int n,int mx){
vector<vector<bool>> dp(n+1,vector<bool>(mx+1,false));
dp[0][0]=true;
rep(i,mx) rep(j,n) dp[i+1][j]=(dp[i][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 |
1230 Byte |
Status |
RE |
Exec Time |
101 ms |
Memory |
256 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 |
RE |
101 ms |
256 KB |
01 |
RE |
100 ms |
256 KB |
02 |
RE |
101 ms |
256 KB |
90 |
RE |
100 ms |
256 KB |
91 |
RE |
100 ms |
256 KB |