結果
問題 | No.1996 <>< |
ユーザー | 👑 rin204 |
提出日時 | 2022-07-01 21:53:01 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 653 ms / 2,000 ms |
コード長 | 1,390 bytes |
コンパイル時間 | 180 ms |
コンパイル使用メモリ | 82,688 KB |
実行使用メモリ | 83,592 KB |
最終ジャッジ日時 | 2024-05-04 16:16:55 |
合計ジャッジ時間 | 9,064 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 37 ms
52,224 KB |
testcase_01 | AC | 36 ms
52,096 KB |
testcase_02 | AC | 36 ms
52,480 KB |
testcase_03 | AC | 44 ms
60,416 KB |
testcase_04 | AC | 34 ms
52,096 KB |
testcase_05 | AC | 34 ms
52,352 KB |
testcase_06 | AC | 33 ms
52,864 KB |
testcase_07 | AC | 34 ms
52,736 KB |
testcase_08 | AC | 67 ms
73,968 KB |
testcase_09 | AC | 49 ms
61,056 KB |
testcase_10 | AC | 70 ms
70,656 KB |
testcase_11 | AC | 377 ms
80,444 KB |
testcase_12 | AC | 653 ms
83,592 KB |
testcase_13 | AC | 606 ms
82,256 KB |
testcase_14 | AC | 588 ms
82,104 KB |
testcase_15 | AC | 524 ms
81,468 KB |
testcase_16 | AC | 469 ms
80,312 KB |
testcase_17 | AC | 514 ms
80,840 KB |
testcase_18 | AC | 363 ms
79,688 KB |
testcase_19 | AC | 383 ms
79,920 KB |
testcase_20 | AC | 398 ms
79,832 KB |
testcase_21 | AC | 480 ms
80,380 KB |
testcase_22 | AC | 524 ms
81,308 KB |
testcase_23 | AC | 97 ms
76,484 KB |
testcase_24 | AC | 333 ms
78,804 KB |
testcase_25 | AC | 215 ms
76,976 KB |
testcase_26 | AC | 308 ms
78,344 KB |
testcase_27 | AC | 141 ms
76,104 KB |
testcase_28 | AC | 61 ms
65,536 KB |
testcase_29 | AC | 205 ms
76,708 KB |
testcase_30 | AC | 82 ms
76,124 KB |
testcase_31 | AC | 125 ms
76,160 KB |
testcase_32 | AC | 70 ms
75,804 KB |
ソースコード
MOD = 10 ** 9 + 7 class Bit: def __init__(self, n): self.size = n self.n0 = 1 << (n.bit_length() - 1) self.tree = [0] * (n + 1) def range_sum(self, l, r): return self.sum(r - 1) - self.sum(l - 1) def sum(self, i): i += 1 s = 0 while i > 0: s += self.tree[i] s %= MOD i -= i & -i return s def get(self, i): return self.sum(i) - self.sum(i - 1) def add(self, i, x): i += 1 while i <= self.size: self.tree[i] += x self.tree[i] %= MOD i += i & -i def lower_bound(self, x): pos = 0 plus = self.n0 while plus > 0: if pos + plus <= self.size and self.tree[pos + plus] < x: x -= self.tree[pos + plus] pos += plus plus //= 2 return pos n, k = map(int, input().split()) A = list(map(int, input().split())) S = input() se = set(A) lst = sorted(se) dic = {l:i for i, l in enumerate(lst)} A = [dic[a] for a in A] dp = [1] * n for i in range(k): ndp = [0] * n bit = Bit(n) for j, a in enumerate(A): if S[i] == "<": ndp[j] = bit.sum(a - 1) else: ndp[j] = bit.range_sum(a + 1, n) bit.add(a, dp[j]) dp = ndp print(sum(dp) % MOD)