結果

問題 No.107 モンスター
ユーザー Taiki0715Taiki0715
提出日時 2023-03-28 17:49:47
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 99 ms / 5,000 ms
コード長 1,463 bytes
コンパイル時間 7,297 ms
コンパイル使用メモリ 153,320 KB
実行使用メモリ 7,956 KB
最終ジャッジ日時 2023-10-20 11:35:31
合計ジャッジ時間 8,451 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 23 ms
4,348 KB
testcase_14 AC 48 ms
5,580 KB
testcase_15 AC 47 ms
5,580 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 11 ms
4,348 KB
testcase_18 AC 97 ms
7,956 KB
testcase_19 AC 97 ms
7,956 KB
testcase_20 AC 23 ms
4,348 KB
testcase_21 AC 23 ms
4,348 KB
testcase_22 AC 48 ms
5,580 KB
testcase_23 AC 99 ms
7,956 KB
testcase_24 AC 98 ms
7,956 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <math.h>
#include <cassert>
#include <bitset>
#include <map>
#include <algorithm>
#include <iterator>
#include <string>
#include <utility>
#include <numeric>
#include <regex>
#include <atcoder/all>
using namespace atcoder;
using namespace std;
using ll=long long;
using ull=unsigned long long;
using P=pair<ll,ll>;
template<typename T>using minque=priority_queue<T,vector<T>,greater<T>>;
template<typename T>bool chmax(T &a,const T &b){return (a<b?(a=b,true):false);}
template<typename T>bool chmin(T &a,const T &b){return (a>b?(a=b,true):false);}
template<typename T1,typename T2>
ostream &operator<<(ostream &os,const pair<T1,T2>&p){
  os<<p.first<<" "<<p.second;
  return os;
}
template<typename T1,typename T2>
istream &operator>>(istream &is,pair<T1,T2>&p){
  is>>p.first>>p.second;
  return is;
}
#define reps(i,a,n) for(int i=(a);i<(n);i++)
#define rep(i,n) reps(i,0,n)
#define all(x) x.begin(),x.end()
ll myceil(ll a,ll b){return (a+b-1)/b;}
int main(){
  int n;
  cin>>n;
  vector<int>d(n);
  rep(i,n)cin>>d[i];
  vector<vector<int>>dp(n+1,vector<int>(1<<n,-1e9));
  dp[0][0]=100;
  rep(i,n){
    rep(j,1<<n){
      int mx=100;
      rep(k,n)if((j&(1<<k))&&(d[k]<0))mx+=100;
      rep(k,n)if(dp[i][j]+d[k]>0&&!(j&(1<<k)))chmax(dp[i+1][j|(1<<k)],min(mx,dp[i][j]+d[k]));
    }
  }
  if(dp[n][(1<<n)-1]==-1e9)cout<<0<<endl;
  else cout<<dp[n][(1<<n)-1]<<endl;
}
0