結果

問題 No.2434 RAKUTAN de RAKUTAN
ユーザー shobonvipshobonvip
提出日時 2023-08-12 12:57:10
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 742 bytes
コンパイル時間 383 ms
コンパイル使用メモリ 82,392 KB
実行使用メモリ 164,104 KB
最終ジャッジ日時 2024-04-30 11:15:31
合計ジャッジ時間 4,054 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
52,468 KB
testcase_01 AC 31 ms
53,148 KB
testcase_02 AC 34 ms
52,692 KB
testcase_03 AC 47 ms
65,712 KB
testcase_04 AC 47 ms
65,364 KB
testcase_05 AC 48 ms
65,044 KB
testcase_06 AC 54 ms
66,596 KB
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 AC 385 ms
149,652 KB
testcase_11 AC 394 ms
149,676 KB
testcase_12 AC 405 ms
164,104 KB
testcase_13 AC 376 ms
150,076 KB
testcase_14 AC 381 ms
150,116 KB
testcase_15 AC 48 ms
65,384 KB
testcase_16 AC 47 ms
64,524 KB
testcase_17 AC 48 ms
66,896 KB
testcase_18 AC 47 ms
65,160 KB
testcase_19 AC 41 ms
62,688 KB
testcase_20 AC 49 ms
74,172 KB
testcase_21 AC 50 ms
74,288 KB
testcase_22 AC 32 ms
53,424 KB
testcase_23 AC 39 ms
61,080 KB
testcase_24 WA -
testcase_25 AC 41 ms
60,696 KB
testcase_26 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

n, h, x = map(int,input().split())
G = int(input())
g = set(map(int,input().split()))
B = int(input())
b = set(map(int,input().split()))
newb = set()

for a in b:
	for i in range(a-x, a+x+1):
		if 0 <= i <= n:
			newb.add(i)

ans_base = 0
for a in g:
	if a not in newb:
		ans_base += 1

m = len(newb)
score = [0] * m
newb_list = sorted(list(newb))
for i, a in enumerate(newb_list):
	if a in b:
		score[i] -= 1
	if a in g:
		score[i] += 1

r = min(B, h)
dp = [[- 10 ** 9 for i in range(r+1)] for j in range(m)]
dp[0][0] = 0
for i in range(1, m):
	for j in range(r+1):
		dp[i][j] = max(dp[i][j], dp[i-1][j] + score[i])
		if j >= 1 and i-x >= 0:
			dp[i][j] = max(dp[i][j], dp[i-x][j-1] + score[i])
	
ans = max(dp[m-1])

print(ans + ans_base)

	
0