結果

問題 No.3491 右結合的総乗
コンテスト
ユーザー titia
提出日時 2026-04-11 07:01:29
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 230 ms / 2,000 ms
コード長 383 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 237 ms
コンパイル使用メモリ 85,508 KB
実行使用メモリ 65,448 KB
最終ジャッジ日時 2026-04-11 07:01:42
合計ジャッジ時間 11,550 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 40
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys
input = sys.stdin.readline

N,M=list(map(int,input().split()))
A=list(map(int,input().split()))
S=list(map(int,input().split()))

USE=[0]*(N+1)
Q=[]
ANS=0

for s in S:
    USE[s]=1
    Q.append(s)
    ANS+=1

while Q:
    x=Q.pop()
    for s in S:
        k=A[s+x]

        if USE[k]==1:
            continue
        USE[k]=1
        Q.append(k)
        ANS+=1

print(ANS)
0