結果
| 問題 |
No.107 モンスター
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-10-18 03:56:09 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 489 bytes |
| コンパイル時間 | 495 ms |
| コンパイル使用メモリ | 67,636 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-25 14:00:23 |
| 合計ジャッジ時間 | 1,432 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 20 WA * 1 |
コンパイルメッセージ
main.cpp:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
7 | main()
| ^~~~
ソースコード
#include<iostream>
#include<algorithm>
using namespace std;
int N;
int dp[17][1<<16];
int D[16];
main()
{
cin>>N;
for(int i=0;i<N;i++)cin>>D[i];
dp[1][0]=100;
for(int i=1;i<N;i++)
{
for(int j=0;j<1<<N;j++)
{
if(dp[i][j]==0)continue;
for(int k=0;k<N;k++)
{
if(j>>k&1)continue;
int nxt=j|1<<k;
dp[i+(D[k]<0)][nxt]=max(dp[i+(D[k]<0)][nxt],min(i*100,dp[i][j]+D[k]));
}
}
}
int ans=0;
for(int i=1;i<=N;i++)ans=max(ans,dp[i][(1<<N)-1]);
cout<<ans<<endl;
}