結果
| 問題 |
No.107 モンスター
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2014-12-19 02:18:47 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 703 bytes |
| コンパイル時間 | 518 ms |
| コンパイル使用メモリ | 20,864 KB |
| 実行使用メモリ | 10,752 KB |
| 最終ジャッジ日時 | 2024-06-12 01:36:06 |
| 合計ジャッジ時間 | 7,253 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 9 TLE * 1 -- * 11 |
コンパイルメッセージ
main.c: In function ‘main’:
main.c:35:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
35 | scanf("%d", &num);
| ^~~~~~~~~~~~~~~~~
main.c:37:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
37 | 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, i;
for(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() {
int i;
scanf("%d", &num);
for(i=0; i<num; i++) {
scanf("%d", score+i);
end_mask |= 1 << i;
}
printf("%d\n", getScore(0, 100, 100));
return 0;
}