結果

問題 No.107 モンスター
ユーザー packet0packet0
提出日時 2014-12-19 02:15:07
言語 C90
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 699 bytes
コンパイル時間 1,267 ms
コンパイル使用メモリ 24,168 KB
実行使用メモリ 4,376 KB
最終ジャッジ日時 2023-09-02 19:10:05
合計ジャッジ時間 7,286 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#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;
}
0