結果
問題 | No.2434 RAKUTAN de RAKUTAN |
ユーザー | chineristAC |
提出日時 | 2023-08-18 23:43:23 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,432 bytes |
コンパイル時間 | 225 ms |
コンパイル使用メモリ | 82,028 KB |
実行使用メモリ | 315,136 KB |
最終ジャッジ日時 | 2024-11-28 11:18:34 |
合計ジャッジ時間 | 5,335 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 37 ms
54,068 KB |
testcase_01 | AC | 37 ms
53,492 KB |
testcase_02 | AC | 42 ms
60,088 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | AC | 36 ms
53,452 KB |
testcase_08 | AC | 40 ms
53,760 KB |
testcase_09 | AC | 37 ms
53,140 KB |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | AC | 464 ms
314,240 KB |
testcase_21 | AC | 453 ms
314,116 KB |
testcase_22 | AC | 39 ms
52,992 KB |
testcase_23 | AC | 53 ms
64,128 KB |
testcase_24 | AC | 60 ms
66,884 KB |
testcase_25 | AC | 52 ms
63,872 KB |
testcase_26 | AC | 55 ms
62,976 KB |
ソースコード
import sys from itertools import permutations from heapq import * input = lambda :sys.stdin.readline().rstrip() mi = lambda :map(int,input().split()) li = lambda :list(mi()) class SegmentTree: def __init__(self, init_val, segfunc, ide_ele): n = len(init_val) self.segfunc = segfunc self.ide_ele = ide_ele self.num = 1 << (n - 1).bit_length() self.tree = [ide_ele] * 2 * self.num self.size = n for i in range(n): self.tree[self.num + i] = init_val[i] for i in range(self.num - 1, 0, -1): self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1]) def update(self, k, x): k += self.num self.tree[k] = self.segfunc(self.tree[k],x) while k > 1: k >>= 1 self.tree[k] = self.segfunc(self.tree[2*k], self.tree[2*k+1]) def query(self, l, r): if r==self.size: r = self.num res = self.ide_ele l += self.num r += self.num right = [] while l < r: if l & 1: res = self.segfunc(res, self.tree[l]) l += 1 if r & 1: right.append(self.tree[r-1]) l >>= 1 r >>= 1 for e in right[::-1]: res = self.segfunc(res,e) return res N,H,X = mi() G = int(input()) G = li() B = int(input()) B = li() day = set([0,N]) for i in range(X+1): day.add(i) for i in range(X+1): if 0 <= N-i: day.add(N-i) for g in G: for i in range(-2*X,2*X+1): if 0 <= g+i <= N: day.add(g+i) for b in B: for i in range(-2*X,2*X+1): if 0 <= b+i <= N: day.add(b+i) day = sorted(day) d_to_i = {d:i for i,d in enumerate(day)} n = len(day) M = max(len(G),len(B)) INF = H + 1 dp = [[INF]*(2*M+1) for i in range(n)] dp[0][0] = 0 G = set(G) B = set(B) for i in range(1,n): d = day[i] p = 0 if d in G: p = 1 elif d in B: p = -1 for h in range(-M,M+1): if dp[i-1][h] == INF: continue dp[i][h+p] = min(dp[i][h+p],dp[i-1][h]) if i-X in d_to_i: pre = d_to_i[i-X] for h in range(-M,M+1): if dp[pre][h] == INF: continue dp[i][h+p] = min(dp[i][h+p],dp[pre][h]+1) for tani in range(-M,M+1)[::-1]: if dp[-1][tani] <= H: print(tani) break