結果

問題 No.1544 [Cherry 2nd Tune C] Synchroscope
ユーザー Manuel1024
提出日時 2021-05-25 02:10:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 159 ms / 2,000 ms
コード長 334 bytes
コンパイル時間 351 ms
コンパイル使用メモリ 82,076 KB
実行使用メモリ 62,660 KB
最終ジャッジ日時 2024-12-14 21:36:58
合計ジャッジ時間 4,978 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 48
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ans = -1

lim = n*m
ind = 0
ai = 0
bi = 0
while ind < lim:
    if a[ai] == b[bi]:
        ans = ind+1
        break
    ind += 1
    ai += 1
    bi += 1
    if ai == n:
        ai -= n
    if bi == m:
        bi -= m

print(ans)
0