結果

問題 No.2999 Long Long Friedrice
ユーザー flippergo
提出日時 2025-06-21 12:36:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 80 ms / 2,000 ms
コード長 503 bytes
コンパイル時間 505 ms
コンパイル使用メモリ 82,232 KB
実行使用メモリ 66,560 KB
最終ジャッジ日時 2025-06-21 12:36:51
合計ジャッジ時間 3,890 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
G = {1:set()}
for i in range(N):
    a = A[i]
    b = B[i]
    if a not in G:
        G[a] = set()
    if a+b not in G[a]:
        G[a].add(a+b)
        if a+b not in G:
            G[a+b] = set()
que = deque([1])
visited = set([1])
while que:
    x = que.popleft()
    for y in G[x]:
        if y not in visited:
            visited.add(y)
            que.append(y)
print(max(visited))
0