Submission #5430573
Source Code Expand
#include <bits/stdc++.h> using namespace std; #define FOR(i,n) for(int i=0;i<n;i++) #define MOD 1000000007 typedef long long ll; template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}} template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}} template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;} template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);} int main(){ int n; cin >> n; int p[1000],sum=0; FOR(i,n){ cin >> p[i]; sum+=p[i]; } bool dp[100000]={0}; dp[0]=1; FOR(j,n){ for(int i=sum;i>=0;i--){ if(i>=p[j] && dp[i-p[j]]){ dp[i]=1; } } } int ans=0; FOR(i,10001){ if(dp[i]){ ans++; } } cout << ans << endl; }
Submission Info
Submission Time | |
---|---|
Task | A - コンテスト |
User | J190353UJ |
Language | C++14 (GCC 5.4.1) |
Score | 2 |
Code Size | 828 Byte |
Status | AC |
Exec Time | 2 ms |
Memory | 384 KB |
Judge Result
Set Name | All | ||
---|---|---|---|
Score / Max Score | 2 / 2 | ||
Status |
|
Set Name | Test Cases |
---|---|
All | 00, 01, 02, 90, 91 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00 | AC | 1 ms | 384 KB |
01 | AC | 1 ms | 384 KB |
02 | AC | 2 ms | 384 KB |
90 | AC | 1 ms | 384 KB |
91 | AC | 1 ms | 384 KB |