結果

問題 No.1859 ><<<
ユーザー ああいいああいい
提出日時 2022-02-28 13:26:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 353 ms / 2,000 ms
コード長 636 bytes
コンパイル時間 276 ms
コンパイル使用メモリ 87,096 KB
実行使用メモリ 147,408 KB
最終ジャッジ日時 2023-09-20 20:56:57
合計ジャッジ時間 14,196 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,280 KB
testcase_01 AC 71 ms
71,280 KB
testcase_02 AC 70 ms
71,336 KB
testcase_03 AC 70 ms
71,580 KB
testcase_04 AC 221 ms
146,892 KB
testcase_05 AC 353 ms
147,088 KB
testcase_06 AC 200 ms
147,308 KB
testcase_07 AC 210 ms
147,152 KB
testcase_08 AC 218 ms
147,172 KB
testcase_09 AC 200 ms
147,408 KB
testcase_10 AC 111 ms
86,416 KB
testcase_11 AC 159 ms
121,100 KB
testcase_12 AC 151 ms
115,452 KB
testcase_13 AC 128 ms
99,560 KB
testcase_14 AC 161 ms
107,540 KB
testcase_15 AC 185 ms
130,572 KB
testcase_16 AC 202 ms
136,404 KB
testcase_17 AC 173 ms
110,912 KB
testcase_18 AC 200 ms
136,420 KB
testcase_19 AC 173 ms
107,548 KB
testcase_20 AC 195 ms
130,828 KB
testcase_21 AC 205 ms
139,784 KB
testcase_22 AC 198 ms
136,736 KB
testcase_23 AC 192 ms
130,340 KB
testcase_24 AC 190 ms
139,156 KB
testcase_25 AC 219 ms
136,836 KB
testcase_26 AC 189 ms
130,812 KB
testcase_27 AC 204 ms
136,624 KB
testcase_28 AC 197 ms
135,908 KB
testcase_29 AC 197 ms
135,776 KB
testcase_30 AC 193 ms
130,472 KB
testcase_31 AC 189 ms
130,280 KB
testcase_32 AC 218 ms
139,344 KB
testcase_33 AC 194 ms
130,704 KB
testcase_34 AC 200 ms
136,456 KB
testcase_35 AC 210 ms
139,524 KB
testcase_36 AC 204 ms
139,508 KB
testcase_37 AC 192 ms
130,580 KB
testcase_38 AC 208 ms
139,980 KB
testcase_39 AC 201 ms
139,524 KB
testcase_40 AC 190 ms
138,912 KB
testcase_41 AC 192 ms
139,472 KB
testcase_42 AC 200 ms
130,412 KB
testcase_43 AC 189 ms
136,548 KB
testcase_44 AC 188 ms
136,564 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int,input().split()))
S = input()
T = []
for i in range(N-1):
    if A[i] < A[i+1]:
        T.append('<')
    else:
        T.append(">")
if A[-1] < A[0]:
    T.append("<")
else:
    T.append(">")
    
T = "".join(T)
T = S + T + T
n = len(T)
Z = [0] * n
Z[0] = n
i = 1
j = 0
while i < n:
    while i + j < n and T[i+j] == T[j]:
        j += 1
    Z[i] = j
    if j == 0:
        i += 1
        continue
    k = 1
    while k < j and k + Z[k] < j:
        Z[i+k] = Z[k]
        k += 1
    i += k
    j -= k
import sys
for i in range(N-1,n):
    if Z[i] >= N-1:
        print(i-N+1)
        exit()
print(-1)
0