結果

問題 No.1535 五七五
ユーザー SidewaysOwlSidewaysOwl
提出日時 2021-10-22 09:38:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 362 ms / 2,000 ms
コード長 671 bytes
コンパイル時間 213 ms
コンパイル使用メモリ 81,816 KB
実行使用メモリ 270,536 KB
最終ジャッジ日時 2023-10-23 16:40:47
合計ジャッジ時間 5,798 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
55,624 KB
testcase_01 AC 41 ms
55,624 KB
testcase_02 AC 41 ms
55,624 KB
testcase_03 AC 39 ms
55,624 KB
testcase_04 AC 357 ms
270,536 KB
testcase_05 AC 349 ms
264,080 KB
testcase_06 AC 362 ms
269,024 KB
testcase_07 AC 38 ms
55,624 KB
testcase_08 AC 39 ms
55,624 KB
testcase_09 AC 39 ms
55,624 KB
testcase_10 AC 39 ms
55,624 KB
testcase_11 AC 39 ms
55,624 KB
testcase_12 AC 39 ms
55,624 KB
testcase_13 AC 38 ms
55,624 KB
testcase_14 AC 38 ms
55,624 KB
testcase_15 AC 39 ms
55,624 KB
testcase_16 AC 39 ms
55,624 KB
testcase_17 AC 39 ms
55,624 KB
testcase_18 AC 248 ms
179,704 KB
testcase_19 AC 242 ms
165,952 KB
testcase_20 AC 245 ms
165,704 KB
testcase_21 AC 248 ms
170,132 KB
testcase_22 AC 260 ms
168,620 KB
testcase_23 AC 243 ms
168,616 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
abc = list(map(int,input().split()))
from collections import defaultdict
ss = list(input().split())
s = []
for i in range(n):
    s.append(len(ss[i]))
d = [defaultdict(int) for _ in range(3)]
for cnt,a in enumerate(abc):
    j = -1
    sum_ = 0
    for i in range(n):
        while j+1 <= n-1 and sum_ + s[j+1] < a:
            j += 1
            sum_ += s[j]
        if j+1 <= n-1 and sum_ + s[j+1] ==  a:
#             print(sum_,cnt,i,j,"a")
            d[cnt][i] = j+1
        sum_ -= s[i]
ans = 0
for k in d[0].keys():
#     print(k)
    b = d[0][k] + 1
    if b in d[1]:
        c = d[1][b] + 1
        if c in d[2]:
            ans += 1
print(ans)
0