結果
問題 | No.1996 <>< |
ユーザー | 👑 rin204 |
提出日時 | 2022-07-01 21:53:01 |
言語 | PyPy3 (7.3.13) |
結果 |
AC
|
実行時間 | 1,061 ms / 2,000 ms |
コード長 | 1,390 bytes |
コンパイル時間 | 391 ms |
コンパイル使用メモリ | 87,136 KB |
実行使用メモリ | 84,456 KB |
最終ジャッジ日時 | 2023-08-17 09:25:48 |
合計ジャッジ時間 | 13,198 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 70 ms
71,584 KB |
testcase_01 | AC | 72 ms
71,420 KB |
testcase_02 | AC | 72 ms
71,420 KB |
testcase_03 | AC | 82 ms
76,272 KB |
testcase_04 | AC | 69 ms
71,384 KB |
testcase_05 | AC | 70 ms
71,288 KB |
testcase_06 | AC | 70 ms
71,432 KB |
testcase_07 | AC | 71 ms
71,420 KB |
testcase_08 | AC | 97 ms
77,148 KB |
testcase_09 | AC | 80 ms
76,300 KB |
testcase_10 | AC | 96 ms
76,540 KB |
testcase_11 | AC | 603 ms
81,248 KB |
testcase_12 | AC | 1,061 ms
84,456 KB |
testcase_13 | AC | 886 ms
83,176 KB |
testcase_14 | AC | 842 ms
83,580 KB |
testcase_15 | AC | 757 ms
82,928 KB |
testcase_16 | AC | 653 ms
81,656 KB |
testcase_17 | AC | 731 ms
83,048 KB |
testcase_18 | AC | 470 ms
80,680 KB |
testcase_19 | AC | 516 ms
80,964 KB |
testcase_20 | AC | 539 ms
81,108 KB |
testcase_21 | AC | 628 ms
81,796 KB |
testcase_22 | AC | 741 ms
83,488 KB |
testcase_23 | AC | 134 ms
77,356 KB |
testcase_24 | AC | 482 ms
80,528 KB |
testcase_25 | AC | 290 ms
78,180 KB |
testcase_26 | AC | 401 ms
80,380 KB |
testcase_27 | AC | 164 ms
77,448 KB |
testcase_28 | AC | 85 ms
76,432 KB |
testcase_29 | AC | 268 ms
78,152 KB |
testcase_30 | AC | 106 ms
77,360 KB |
testcase_31 | AC | 178 ms
77,616 KB |
testcase_32 | AC | 94 ms
77,344 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)