Submission #2546687
Source Code Expand
#include <bits/stdc++.h> #define rep(i,j,k) for(ll i=(ll)j;i<(ll)k;i++) #define itrep(i,x) for(auto i=(x).begin(); i!=(x).end();i++) #define Sort(x) sort((x).begin(),(x).end()) #define all(x) (x).begin(),(x).end() #define fi first #define se second #define vec vector #define INF INT_MAX #define INFL 1e18 #define MOD 1000000007 #define pb push_back #define MP make_pair #define PI 3.1415926535 typedef long long int ll; typedef std::pair<int,int> P; int D=1; int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0}; using namespace std; int main(){ int n; cin>>n; vec<vec<bool>> dp(n+1,vec<bool>(10010,false)); dp[0][0]=true; rep(i,0,n){ int x; cin>>x; rep(j,0,10001){ if(j<x)dp[i+1][j]=dp[i][j]; else { if(dp[i][j]||dp[i][j-x])dp[i+1][j]=true; } } } int ans=0; rep(i,0,10001){ if(dp[n][i])ans++; } cout<<ans<<endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - コンテスト |
User | gotutiyan |
Language | C++14 (GCC 5.4.1) |
Score | 2 |
Code Size | 980 Byte |
Status | AC |
Exec Time | 3 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 | 256 KB |
01 | AC | 2 ms | 256 KB |
02 | AC | 3 ms | 384 KB |
90 | AC | 1 ms | 256 KB |
91 | AC | 1 ms | 256 KB |