結果

問題 No.2434 RAKUTAN de RAKUTAN
ユーザー shobonvipshobonvip
提出日時 2023-08-11 18:42:41
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,686 bytes
コンパイル時間 3,808 ms
コンパイル使用メモリ 263,624 KB
実行使用メモリ 814,780 KB
最終ジャッジ日時 2024-04-30 11:13:14
合計ジャッジ時間 8,716 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 639 ms
415,372 KB
testcase_04 AC 617 ms
415,316 KB
testcase_05 AC 633 ms
415,400 KB
testcase_06 AC 619 ms
415,400 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 1 ms
6,944 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 MLE -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

//* ATCODER
#include<atcoder/all>
using namespace atcoder;
typedef modint998244353 mint;
//*/

/* BOOST MULTIPRECISION
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
//*/

typedef long long ll;

#define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
#define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--)

template <typename T> bool chmin(T &a, const T &b) {
	if (a <= b) return false;
	a = b;
	return true;
}

template <typename T> bool chmax(T &a, const T &b) {
	if (a >= b) return false;
	a = b;
	return true;
}

template <typename T> T max(vector<T> &a){
	assert(!a.empty());
	T ret = a[0];
	for (int i=0; i<(int)a.size(); i++) chmax(ret, a[i]);
	return ret;
}

template <typename T> T min(vector<T> &a){
	assert(!a.empty());
	T ret = a[0];
	for (int i=0; i<(int)a.size(); i++) chmin(ret, a[i]);
	return ret;
}

template <typename T> T sum(vector<T> &a){
	T ret = 0;
	for (int i=0; i<(int)a.size(); i++) ret += a[i];
	return ret;
}

int main(){
	int n, h, x; cin >> n >> h >> x;
	int G; cin >> G;
	vector<int> g(G);
	rep(i,0,G) cin >> g[i];
	int B; cin >> B;
	vector<int> b(B);
	rep(i,0,B) cin >> b[i];

	vector<int> score(n);
	rep(i,0,G) score[g[i]-1] = 1;
	rep(i,0,B) score[b[i]-1] = - 1;

	vector<vector<int>> dp(n+1, vector<int>(201, 1e9));
	dp[0][100] = 0;
	rep(i,0,n){
		rep(j,0,201){
			if (0 <= j+score[i] && j+score[i] <= 200){
				if (i+1-x >= 0){
					chmin(dp[i+1][j+score[i]], dp[i+1-x][j] + 1);
				}
				chmin(dp[i+1][j+score[i]], dp[i][j]);
			}
		}
	}
	int ans = -113;
	rep(i,0,201){
		if (dp[n][i] <= h){
			chmax(ans, i - 100);
		}
	}

	cout << ans << '\n';

}

0