結果

問題 No.107 モンスター
ユーザー omochana1omochana1
提出日時 2014-12-21 02:30:05
言語 C++11
(gcc 11.4.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,270 bytes
コンパイル時間 672 ms
コンパイル使用メモリ 86,760 KB
実行使用メモリ 7,852 KB
最終ジャッジ日時 2023-09-02 20:29:33
合計ジャッジ時間 1,971 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,368 KB
testcase_01 AC 1 ms
4,368 KB
testcase_02 AC 2 ms
4,368 KB
testcase_03 AC 2 ms
4,372 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,368 KB
testcase_06 AC 2 ms
4,372 KB
testcase_07 AC 2 ms
4,368 KB
testcase_08 AC 1 ms
4,368 KB
testcase_09 AC 1 ms
4,368 KB
testcase_10 AC 1 ms
4,368 KB
testcase_11 AC 2 ms
4,372 KB
testcase_12 AC 2 ms
4,372 KB
testcase_13 AC 4 ms
4,436 KB
testcase_14 AC 5 ms
4,648 KB
testcase_15 AC 5 ms
4,436 KB
testcase_16 AC 1 ms
4,368 KB
testcase_17 AC 2 ms
4,368 KB
testcase_18 AC 5 ms
4,984 KB
testcase_19 AC 5 ms
4,908 KB
testcase_20 AC 4 ms
4,600 KB
testcase_21 AC 4 ms
4,460 KB
testcase_22 AC 6 ms
5,860 KB
testcase_23 AC 9 ms
7,852 KB
testcase_24 AC 6 ms
5,252 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <string.h>
#include <map>
#include <fstream>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <set>
#include <climits>
#define MAX_N 1000100
#define PI 3.141592653589
#define EPS 1e-20
#define BS 10
#define MOD 1000000009 
#define ZERO 10001
#define YJSNPI 8101919
#define INF (1 << 28)
#define ADD(a, b) a = (a + (ll)b) % MOD
#define MUL(a, b) a = (a * (ll)b) % MOD
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)


using namespace std;

typedef pair<int, int> pi;
typedef pair<pi, pi> ppi;

int N;
int dp[1 << 16][17];
int A[17];

int main() {
	cin >> N;
	for(int i = 0; i < N; i++) cin >> A[i];
	dp[0][1] = 100;
	for(int i = 0; i < 1 << N; i++) {
		for(int j = 1; j <= N; j++) {
			if(dp[i][j] == 0) continue;
			for(int k = 0; k < N; k++) {
				if(i & (1 << k)) continue;
				if(A[k] < 0) {
					if(dp[i][j] + A[k] > 0) {
						MAX(dp[i | (1 << k)][j + 1], dp[i][j] + A[k]);
					}
				}
				else {
					MAX(dp[i | (1 << k)][j], min(j * 100, dp[i][j] + A[k]));
				}
			}
		}
	}
	int res = 0;
	for(int i = 1; i <= N; i++) MAX(res, dp[(1 << N) - 1][i]);
	cout << res << endl;
}
0