結果
問題 | No.1378 Flattening |
ユーザー | mkawa2 |
提出日時 | 2022-06-28 02:16:49 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,470 bytes |
コンパイル時間 | 218 ms |
コンパイル使用メモリ | 82,916 KB |
実行使用メモリ | 79,652 KB |
最終ジャッジ日時 | 2024-11-20 11:32:07 |
合計ジャッジ時間 | 10,140 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 38 ms
52,352 KB |
testcase_01 | AC | 39 ms
52,992 KB |
testcase_02 | AC | 37 ms
52,736 KB |
testcase_03 | AC | 39 ms
52,608 KB |
testcase_04 | AC | 38 ms
52,224 KB |
testcase_05 | AC | 39 ms
52,480 KB |
testcase_06 | AC | 39 ms
52,480 KB |
testcase_07 | AC | 41 ms
52,480 KB |
testcase_08 | AC | 37 ms
52,352 KB |
testcase_09 | AC | 38 ms
52,864 KB |
testcase_10 | AC | 39 ms
52,480 KB |
testcase_11 | AC | 38 ms
52,096 KB |
testcase_12 | AC | 39 ms
52,352 KB |
testcase_13 | AC | 39 ms
52,224 KB |
testcase_14 | AC | 39 ms
52,096 KB |
testcase_15 | AC | 38 ms
52,736 KB |
testcase_16 | AC | 39 ms
52,480 KB |
testcase_17 | AC | 38 ms
52,224 KB |
testcase_18 | AC | 40 ms
52,736 KB |
testcase_19 | AC | 41 ms
51,968 KB |
testcase_20 | AC | 40 ms
52,608 KB |
testcase_21 | AC | 40 ms
52,224 KB |
testcase_22 | AC | 40 ms
52,736 KB |
testcase_23 | AC | 39 ms
52,352 KB |
testcase_24 | AC | 38 ms
52,096 KB |
testcase_25 | AC | 40 ms
52,608 KB |
testcase_26 | AC | 38 ms
52,736 KB |
testcase_27 | AC | 37 ms
52,608 KB |
testcase_28 | AC | 39 ms
52,584 KB |
testcase_29 | AC | 38 ms
52,608 KB |
testcase_30 | AC | 36 ms
52,480 KB |
testcase_31 | WA | - |
testcase_32 | AC | 538 ms
79,084 KB |
testcase_33 | WA | - |
testcase_34 | AC | 458 ms
79,076 KB |
testcase_35 | AC | 420 ms
78,976 KB |
testcase_36 | AC | 404 ms
79,232 KB |
testcase_37 | WA | - |
testcase_38 | AC | 411 ms
79,336 KB |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | AC | 414 ms
79,532 KB |
testcase_42 | WA | - |
testcase_43 | WA | - |
testcase_44 | WA | - |
testcase_45 | AC | 108 ms
76,800 KB |
testcase_46 | AC | 129 ms
76,660 KB |
testcase_47 | AC | 73 ms
73,984 KB |
testcase_48 | WA | - |
testcase_49 | AC | 368 ms
78,988 KB |
testcase_50 | WA | - |
testcase_51 | AC | 48 ms
60,032 KB |
ソースコード
import sys # sys.setrecursionlimit(200005) int1 = lambda x: int(x)-1 pDB = lambda *x: print(*x, end="\n", file=sys.stderr) p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr) def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LI1(): return list(map(int1, sys.stdin.readline().split())) def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def SI(): return sys.stdin.readline().rstrip() # dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] # dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] inf = (1 << 63)-1 # inf = (1 << 31)-1 # md = 10**9+7 md = 998244353 n = II() aa = LI() ll = [0]*n rr = [0]*n st = [(-1, -1)] for i, a in enumerate(aa): while st[-1][-1] > a: st.pop() ll[i] = st[-1][0]+1 st.append((i, a)) # pDB(ll) st = [(n, -1)] for i in range(n)[::-1]: a = aa[i] while st[-1][-1] > a: st.pop() rr[i] = st[-1][0] st.append((i, a)) # pDB(rr) dp = [1]+[0]*n cs = [0]+[1]*(n+1) for i, a in enumerate(aa): ndp = [0]*(n+1) ncs = [0]*(n+2) l, r = ll[i], rr[i] for j in range(n+1): ndp[j]=dp[j] if l <= j <= r and (j > i or r < n): if l == 0 and j>i: ndp[j] += cs[i+1]-cs[l] else: ndp[j] += cs[j]-cs[l] ncs[j+1] = (ncs[j]+ndp[j])%md dp = ndp cs = ncs print(dp[n])