結果
問題 | No.2434 RAKUTAN de RAKUTAN |
ユーザー | chineristAC |
提出日時 | 2023-08-18 23:43:23 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,432 bytes |
コンパイル時間 | 368 ms |
コンパイル使用メモリ | 81,792 KB |
実行使用メモリ | 314,880 KB |
最終ジャッジ日時 | 2024-05-06 06:31:54 |
合計ジャッジ時間 | 5,648 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 39 ms
52,864 KB |
testcase_01 | AC | 40 ms
53,120 KB |
testcase_02 | AC | 44 ms
59,904 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | AC | 39 ms
52,864 KB |
testcase_08 | AC | 39 ms
52,736 KB |
testcase_09 | AC | 39 ms
53,376 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 | 475 ms
314,240 KB |
testcase_21 | AC | 477 ms
313,984 KB |
testcase_22 | AC | 39 ms
53,504 KB |
testcase_23 | AC | 53 ms
63,616 KB |
testcase_24 | AC | 58 ms
67,328 KB |
testcase_25 | AC | 52 ms
63,872 KB |
testcase_26 | AC | 49 ms
62,464 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