結果
| 問題 | 
                            No.1535 五七五
                             | 
                    
| コンテスト | |
| ユーザー | 
                             SidewaysOwl
                         | 
                    
| 提出日時 | 2021-10-22 09:38:06 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 369 ms / 2,000 ms | 
| コード長 | 671 bytes | 
| コンパイル時間 | 353 ms | 
| コンパイル使用メモリ | 82,220 KB | 
| 実行使用メモリ | 271,004 KB | 
| 最終ジャッジ日時 | 2024-09-22 10:49:16 | 
| 合計ジャッジ時間 | 5,883 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 21 | 
ソースコード
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)
            
            
            
        
            
SidewaysOwl