結果
問題 |
No.107 モンスター
|
ユーザー |
|
提出日時 | 2020-06-08 00:21:13 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 13 ms / 5,000 ms |
コード長 | 413 bytes |
コンパイル時間 | 2,025 ms |
コンパイル使用メモリ | 192,688 KB |
最終ジャッジ日時 | 2025-01-11 00:00:58 |
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 21 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:8:27: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 8 | int n,a[16]; scanf("%d",&n); | ~~~~~^~~~~~~~~ main.cpp:9:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 9 | rep(i,n) scanf("%d",&a[i]); | ~~~~~^~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(n);i++) using namespace std; int main(){ int n,a[16]; scanf("%d",&n); rep(i,n) scanf("%d",&a[i]); int dp[1<<16]={100}; rep(S,1<<n){ int hp=100; rep(i,n) if((S>>i&1)==1 && a[i]<0) hp+=100; rep(i,n) if((S>>i&1)==0 && dp[S]>0 && dp[S]>-a[i]) { dp[S|1<<i]=max(dp[S|1<<i],min(dp[S]+a[i],hp)); } } printf("%d\n",dp[(1<<n)-1]); return 0; }