結果

問題 No.107 モンスター
ユーザー uw_yu1rabbituw_yu1rabbit
提出日時 2021-02-05 00:42:27
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,492 bytes
コンパイル時間 1,322 ms
コンパイル使用メモリ 84,300 KB
実行使用メモリ 8,116 KB
最終ジャッジ日時 2023-09-13 21:10:11
合計ジャッジ時間 13,271 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<cstdint>
#include<algorithm>
#include<cstddef>
#include<vector>
//#include<atcoder/all>
//using namespace atcoder;
using namespace std;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using usize = size_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using i128 = __int128_t;
using u128 = __uint128_t;
using ld = long double;
template<typename T>
using vec = vector<T>;
#define rep(i, n) for (i64 i = 0; i < (i64)(n); ++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define len(hoge) (i64)((hoge).size())
using P = pair<i64,i64>;
template<class T, class S> ostream &operator<<(ostream &os, const pair<T,S> &p){
	os << p.first << " " << p.second;
	return os;
}
void solve(){
}
int main(){
	ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	i64 n;
	cin >> n;
	vec<i64> d(n);
	rep(i,n)cin >> d[i];
	vec<i64> dp(1 << n);
	vec<i64> mx = dp;
	mx[0] = 100;
	for(i64 Set = 1; Set < (1 << n); Set++){
		rep(bit,n){
			if(Set & (1 << bit)){
				if(d[bit] < 0)mx[Set] = mx[Set ^ (1 << bit)] + 100;
				else mx[Set] = mx[Set ^ (1 << bit)];
				break;
			}
		}
		dp[0] = 100;
		rep(Set, (1 << n)){
			if(dp[Set] == 0)continue;
			rep(bit,n){
				if(!(Set & (1 << bit))){
					i64 k = min(dp[Set] + d[bit], mx[Set | (1 << bit)]);
					dp[Set | (1 << bit)] = max(dp[Set | (1 << bit)], k);
				}
			}
		}
	}
	cout << dp.back() << endl;
}
0