#include #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 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