結果
問題 | No.1996 <>< |
ユーザー | aaaaaaaaaa2230 |
提出日時 | 2022-07-01 22:17:29 |
言語 | PyPy3 (7.3.13) |
結果 |
AC
|
実行時間 | 817 ms / 2,000 ms |
コード長 | 1,238 bytes |
コンパイル時間 | 329 ms |
コンパイル使用メモリ | 87,100 KB |
実行使用メモリ | 95,640 KB |
最終ジャッジ日時 | 2023-08-17 09:49:57 |
合計ジャッジ時間 | 13,435 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 78 ms
71,360 KB |
testcase_01 | AC | 76 ms
71,408 KB |
testcase_02 | AC | 76 ms
71,348 KB |
testcase_03 | AC | 82 ms
76,032 KB |
testcase_04 | AC | 75 ms
71,440 KB |
testcase_05 | AC | 75 ms
71,268 KB |
testcase_06 | AC | 77 ms
71,228 KB |
testcase_07 | AC | 77 ms
71,364 KB |
testcase_08 | AC | 96 ms
76,600 KB |
testcase_09 | AC | 84 ms
76,008 KB |
testcase_10 | AC | 97 ms
76,568 KB |
testcase_11 | AC | 602 ms
86,712 KB |
testcase_12 | AC | 767 ms
95,640 KB |
testcase_13 | AC | 817 ms
95,620 KB |
testcase_14 | AC | 778 ms
94,992 KB |
testcase_15 | AC | 733 ms
92,636 KB |
testcase_16 | AC | 702 ms
90,972 KB |
testcase_17 | AC | 729 ms
92,840 KB |
testcase_18 | AC | 535 ms
86,636 KB |
testcase_19 | AC | 633 ms
88,140 KB |
testcase_20 | AC | 638 ms
87,512 KB |
testcase_21 | AC | 661 ms
90,788 KB |
testcase_22 | AC | 795 ms
93,324 KB |
testcase_23 | AC | 118 ms
78,200 KB |
testcase_24 | AC | 495 ms
86,876 KB |
testcase_25 | AC | 263 ms
82,104 KB |
testcase_26 | AC | 472 ms
84,684 KB |
testcase_27 | AC | 162 ms
79,076 KB |
testcase_28 | AC | 89 ms
75,956 KB |
testcase_29 | AC | 297 ms
81,864 KB |
testcase_30 | AC | 103 ms
77,548 KB |
testcase_31 | AC | 151 ms
79,056 KB |
testcase_32 | AC | 102 ms
77,116 KB |
ソースコード
mod = 10**9+7 class BIT: def __init__(self, n): self.size = n self.tree = [0]*(n+1) def build(self, list): self.tree[1:] = list.copy() for i in range(self.size+1): j = i + (i & (-i)) if j < self.size+1: self.tree[j] += self.tree[i] def sum(self, i): # [0, i) の要素の総和を返す s = 0 while i>0: s += self.tree[i] s %= mod i -= i & -i return s # 0 index を 1 index に変更 転倒数を求めるなら1を足していく def add(self, i, x): i += 1 while i <= self.size: self.tree[i] += x self.tree[i] %= mod i += i & -i n,k = map(int,input().split()) A = list(map(int,input().split())) S = input() dic = {a:i for i,a in enumerate(sorted(set(A)),1)} l = len(dic)+5 dp = [BIT(l) for i in range(k+1)] for i,a in enumerate(A): s = dic[a] for j in range(min(i+1,k+1)): if j == 0: dp[0].add(s,1) continue if S[j-1] == "<": x = dp[j-1].sum(s) else: x = dp[j-1].sum(l)-dp[j-1].sum(s+1) dp[j].add(s,x) print(dp[k].sum(l))