結果

問題 No.107 モンスター
ユーザー tumuztumuz
提出日時 2023-10-13 10:11:25
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,436 bytes
コンパイル時間 2,038 ms
コンパイル使用メモリ 203,868 KB
実行使用メモリ 9,860 KB
最終ジャッジ日時 2023-10-13 10:11:30
合計ジャッジ時間 3,934 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep1(i,n) for(int i=1; i<=(n); i++)
#define sz(x) int(x.size())
#define all(x) (x).begin(),(x).end()
#define Q2 1000000007
#define Q 998244353
#define lINF LONG_LONG_MAX  //ll
#define iINF INT_MAX //int
#define yes "Yes"
#define no "No"
#define kotae cout<<ans<<endl;
#define dame { puts("0"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
using ll=long long;
using ull=unsigned long long;
using P=pair<int,int>;
using pqg=priority_queue<int,vector<int>,greater<int>>;
using vi=vector<int>;
using vi2=vector<vector<int>>;
using vi3=vector<vector<vector<int>>>;
using vl=vector<ll>;
using vl2=vector<vector<ll>>;
using vl3=vector<vector<vector<ll>>>;
using vs=vector<string>;
using vp=vector<P>;
using vp2=vector<vector<P>>;
void chmax(int &x, int y){ x=max(x,y); return; }
void chmin(int &x, int y){ x=min(x,y); return; }
void chmaxl(ll &x, ll y){ x=max(x,y); return; }
void chminl(ll &x, ll y){ x=min(x,y); return; }

int main() {  

  int n;
  cin >> n;
  vi d(n);
  rep(i,n) cin >> d[i];
  int s=1<<n;
  vi2 dp(s,vector<int>(n));
  dp[0][0]=100;
  rep(i,s)rep(j,n){
    if((i>>j)&1) continue;
    rep(k,n){
      if (d[i]>0) chmax(dp[i|(1<<j)][k], min((k+1)*100,dp[i][k]+d[j]));
      else if(dp[i][k]+d[j]>0) chmax(dp[i|(1<<j)][k+1],dp[i][k]+d[j]);
    }
  }
  int ans=0;
  rep(i,n) chmax(ans,dp[s-1][i]);
  kotae;
  return 0;
}
0