結果
問題 |
No.107 モンスター
|
ユーザー |
|
提出日時 | 2014-12-19 02:15:07 |
言語 | C90 (gcc 12.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 699 bytes |
コンパイル時間 | 353 ms |
コンパイル使用メモリ | 21,248 KB |
実行使用メモリ | 6,656 KB |
最終ジャッジ日時 | 2024-06-12 01:35:48 |
合計ジャッジ時間 | 6,786 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 9 TLE * 1 -- * 11 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:33:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 33 | scanf("%d", &num); | ^~~~~~~~~~~~~~~~~ main.c:35:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 35 | scanf("%d", score+i); | ^~~~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h> #define MAX_MONSTER 16 int num; int score[MAX_MONSTER]; int end_mask = 0; int getScore(const int mask, const int life, const int max_life) { if(mask == end_mask) return life; int max = 0; for(int i=0; i<num; i++) { if(!(mask & 1 << i)) { int tmp_life = life + score[i]; if(tmp_life > 0) { if(tmp_life > max_life) tmp_life = max_life; int tmp = getScore(mask | 1 << i, tmp_life, score[i] < 0 ? max_life + 100 : max_life); if(tmp > max) max = tmp; } } } return max; } int main() { scanf("%d", &num); for(int i=0; i<num; i++) { scanf("%d", score+i); end_mask |= 1 << i; } printf("%d\n", getScore(0, 100, 100)); return 0; }