結果
問題 | No.1996 <>< |
ユーザー | titia |
提出日時 | 2022-07-02 01:33:09 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,135 bytes |
コンパイル時間 | 96 ms |
コンパイル使用メモリ | 11,044 KB |
実行使用メモリ | 13,136 KB |
最終ジャッジ日時 | 2023-08-17 13:28:56 |
合計ジャッジ時間 | 4,026 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 16 ms
12,764 KB |
testcase_01 | AC | 16 ms
8,248 KB |
testcase_02 | AC | 17 ms
8,360 KB |
testcase_03 | AC | 19 ms
8,368 KB |
testcase_04 | AC | 15 ms
8,240 KB |
testcase_05 | AC | 16 ms
8,252 KB |
testcase_06 | AC | 15 ms
8,296 KB |
testcase_07 | AC | 17 ms
8,300 KB |
testcase_08 | AC | 26 ms
8,260 KB |
testcase_09 | AC | 17 ms
8,344 KB |
testcase_10 | AC | 21 ms
8,216 KB |
testcase_11 | TLE | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
ソースコード
import sys input = sys.stdin.readline mod=10**9+7 N,K=map(int,input().split()) A=list(map(int,input().split())) compression_dict={a: ind+1 for ind, a in enumerate(sorted(set(A)))} A=[compression_dict[a] for a in A] # [2, 3, 0, 1, 4] LEN=len(A)+5 def update(v,w): # index vにwを加える while v<=LEN: BIT[v]+=w BIT[v]%=mod v+=(v&(-v)) # v&(-v)で、最も下の立っているビット. 自分を含む大きなノードへ. たとえばv=3→v=4 def getvalue(v): # [1,v]の区間の和を求める ANS=0 while v!=0: ANS+=BIT[v] ANS%=mod v-=(v&(-v)) # 自分より小さい自分の和を構成するノードへ. たとえばv=14→v=12へ return ANS S=input().strip() DP=[1]*N for s in S: BIT=[0]*(LEN+1) NDP=[0]*N if s=="<": for i in range(N): update(A[i],DP[i]) NDP[i]+=getvalue(A[i]-1) NDP[i]%=mod else: for i in range(N): update(A[i],DP[i]) NDP[i]+=getvalue(LEN)-getvalue(A[i]) NDP[i]%=mod DP=NDP print(sum(DP)%mod)