結果

提出番号 853
提出者 ukohank517
言語 C++
提出日時 2017-08-01 15:05:53
問題名 (28)いつだって一位の男、olphe君
結果 AC
点数 100%

テストケース

テストケース 結果 得点 実行時間 メモリ使用量
1 AC 100% 2ms 7680KB
2 AC 100% 1ms 8320KB
3 AC 100% 2ms 7696KB
4 AC 100% 2ms 7776KB
5 AC 100% 2ms 8000KB
6 AC 100% 1ms 7952KB
7 AC 100% 2ms 7792KB
8 AC 100% 1ms 8000KB
9 AC 100% 2ms 7520KB
10 AC 100% 1ms 7696KB
11 AC 100% 2ms 8320KB
12 AC 100% 2ms 8320KB
13 AC 100% 2ms 7984KB
14 AC 100% 2ms 8320KB
15 AC 100% 2ms 7712KB
16 AC 100% 2ms 8320KB
17 AC 100% 2ms 8320KB
18 AC 100% 2ms 7968KB
19 AC 100% 2ms 7424KB
20 AC 100% 2ms 7968KB

ソースコード

#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>

#define MOD 1000000007
#define ll long long

using namespace std;

ll N;
ll S;
vector<ll> p;


int main(){
  ll inp;
  ll dp[10001]={1,0};
  
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> N;
  for(ll i = 0;i<N;i++){
    cin >> inp;
    p.push_back(inp);  
  }
  cin >> S;

  sort(p.begin(), p.end());
  
  for(ll i =0;i<N;i++){
    for(ll j = 0;j<10001;j++){
      inp = p[i]+j;
      if(inp>10000) continue;
      if(dp[j]) {dp[inp]=1;}
    }
  }
  if(S==0) S++;
  for(ll i =S;i<10001;i++){
    if(dp[i]==1){
      cout << i << endl;
      break;
    }
  }
  return 0;
}