結果

問題 No.2434 RAKUTAN de RAKUTAN
ユーザー Astral__Astral__
提出日時 2023-08-12 14:55:43
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 1,618 bytes
コンパイル時間 2,183 ms
コンパイル使用メモリ 206,508 KB
実行使用メモリ 814,652 KB
最終ジャッジ日時 2024-04-30 11:15:46
合計ジャッジ時間 3,778 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 MLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
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


//*/

/* 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>(2001, 1e9));
	dp[0][1000] = 0;
	rep(i,0,n){
		rep(j,0,2001){
			if (0 <= j+score[i] && j+score[i] <= 2000){
				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 = -2000;
	rep(i,0,2001){
		if (dp[n][i] <= h){
			chmax(ans, i - 1000);
		}
	}

	cout << ans << '\n';

}

0