結果

問題 No.1845 Long Substrings
ユーザー 👑 rin204rin204
提出日時 2022-02-18 22:18:44
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 158 ms / 2,000 ms
コード長 233 bytes
コンパイル時間 279 ms
コンパイル使用メモリ 86,968 KB
実行使用メモリ 105,648 KB
最終ジャッジ日時 2023-09-11 19:24:14
合計ジャッジ時間 5,825 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 156 ms
100,680 KB
testcase_01 AC 146 ms
105,504 KB
testcase_02 AC 153 ms
100,944 KB
testcase_03 AC 157 ms
100,728 KB
testcase_04 AC 138 ms
105,648 KB
testcase_05 AC 141 ms
100,044 KB
testcase_06 AC 148 ms
100,520 KB
testcase_07 AC 135 ms
105,616 KB
testcase_08 AC 151 ms
101,712 KB
testcase_09 AC 155 ms
100,612 KB
testcase_10 AC 140 ms
105,500 KB
testcase_11 AC 154 ms
100,056 KB
testcase_12 AC 153 ms
100,132 KB
testcase_13 AC 137 ms
105,576 KB
testcase_14 AC 158 ms
100,764 KB
testcase_15 AC 79 ms
76,668 KB
testcase_16 AC 80 ms
76,356 KB
testcase_17 AC 82 ms
76,552 KB
testcase_18 AC 82 ms
76,680 KB
testcase_19 AC 79 ms
76,588 KB
testcase_20 AC 67 ms
71,140 KB
testcase_21 AC 67 ms
71,240 KB
testcase_22 AC 68 ms
71,256 KB
testcase_23 AC 67 ms
71,360 KB
testcase_24 AC 68 ms
71,156 KB
testcase_25 AC 68 ms
71,132 KB
testcase_26 AC 68 ms
71,224 KB
testcase_27 AC 69 ms
71,232 KB
testcase_28 AC 68 ms
71,472 KB
testcase_29 AC 71 ms
71,368 KB
testcase_30 AC 70 ms
70,964 KB
testcase_31 AC 68 ms
71,168 KB
testcase_32 AC 69 ms
71,440 KB
testcase_33 AC 69 ms
71,264 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 10 ** 9 + 7

n = int(input())
A = list(map(int, input().split()))
S = input()
dp = [0] * 26

for a, s in zip(A, S):
    p = ord(s) - 97
    dp[p] += a * (sum(dp) - dp[p] + 1) % MOD
    dp[p] %= MOD
print(sum(dp) % MOD)
        
0