結果
問題 | No.1996 <>< |
ユーザー | MasKoaTS |
提出日時 | 2022-06-23 15:53:12 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 589 ms / 2,000 ms |
コード長 | 1,416 bytes |
コンパイル時間 | 310 ms |
コンパイル使用メモリ | 82,560 KB |
実行使用メモリ | 94,080 KB |
最終ジャッジ日時 | 2024-05-04 14:50:17 |
合計ジャッジ時間 | 10,646 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 113 ms
85,760 KB |
testcase_01 | AC | 107 ms
86,144 KB |
testcase_02 | AC | 107 ms
86,016 KB |
testcase_03 | AC | 123 ms
88,832 KB |
testcase_04 | AC | 112 ms
86,272 KB |
testcase_05 | AC | 110 ms
86,144 KB |
testcase_06 | AC | 108 ms
86,144 KB |
testcase_07 | AC | 109 ms
86,064 KB |
testcase_08 | AC | 125 ms
88,960 KB |
testcase_09 | AC | 119 ms
89,216 KB |
testcase_10 | AC | 127 ms
89,216 KB |
testcase_11 | AC | 362 ms
91,392 KB |
testcase_12 | AC | 547 ms
93,824 KB |
testcase_13 | AC | 589 ms
93,952 KB |
testcase_14 | AC | 555 ms
94,080 KB |
testcase_15 | AC | 503 ms
92,288 KB |
testcase_16 | AC | 449 ms
92,040 KB |
testcase_17 | AC | 485 ms
92,544 KB |
testcase_18 | AC | 363 ms
91,136 KB |
testcase_19 | AC | 409 ms
91,648 KB |
testcase_20 | AC | 390 ms
91,264 KB |
testcase_21 | AC | 500 ms
92,104 KB |
testcase_22 | AC | 516 ms
92,672 KB |
testcase_23 | AC | 151 ms
89,600 KB |
testcase_24 | AC | 369 ms
90,780 KB |
testcase_25 | AC | 242 ms
89,600 KB |
testcase_26 | AC | 325 ms
90,752 KB |
testcase_27 | AC | 180 ms
89,984 KB |
testcase_28 | AC | 125 ms
88,704 KB |
testcase_29 | AC | 243 ms
89,344 KB |
testcase_30 | AC | 146 ms
88,960 KB |
testcase_31 | AC | 183 ms
89,728 KB |
testcase_32 | AC | 134 ms
89,560 KB |
ソースコード
import itertools as iter import collections as coll import heapq as hq import bisect as bis from decimal import Decimal as dec from functools import cmp_to_key import math import sys #import pypyjit #pypyjit.set_param('max_unroll_recursion=-1') sys.setrecursionlimit(10 ** 6) inp = sys.stdin.readline input = lambda : inp().rstrip() getN = lambda : int(inp()) getNs = lambda : map(int, inp().split()) getList = lambda :list(map(int, inp().split())) getStrs = lambda n : [input() for _ in [0] * n] def yexit(): print("Yes"); exit(0) def nexit(): print("No"); exit(0) pi = 3.141592653589793 mod = 1000000007 MOD = 998244353 INF = 4611686018427387903 dx = [1, 0, -1, 0]; dy = [0, 1, 0, -1] class BIT: def __init__(self, n): self.size = n self.bit = [0] * (n + 1) def add(self, k, p): t = k + 1 while(t <= self.size): self.bit[t] += p self.bit[t] %= mod t += t & -t def sum(self, r): res, t = 0, r while(t > 0): res += self.bit[t] res %= mod t -= t & -t return res """ Main Code """ n, _ = getNs() a = getList() s = input() d = {} for i, k in enumerate(sorted(set(a))): d[k] = i b = [0] * n for i, k in enumerate(a): a[i] = d[k] b[i] = n - 1 - a[i] dp = [1] * n for c in s: lis = a if(c == '<') else b ndp = [0] * n bt = BIT(n) for i, k in enumerate(lis): ndp[i] = bt.sum(k) % mod bt.add(k, dp[i]) dp = ndp[:] ans = 0 for k in dp: ans += k ans %= mod print(ans)