結果

問題 No.1544 [Cherry 2nd Tune C] Synchroscope
ユーザー c-yan
提出日時 2021-06-11 21:49:40
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 416 bytes
コンパイル時間 566 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 22,784 KB
最終ジャッジ日時 2024-12-14 23:10:28
合計ジャッジ時間 37,506 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 3 WA * 34 TLE * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

INF = 10 ** 15

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

result = INF
for i in range(N):
    a = A[i]
    for j in range(M):
        x = i + j * N
        if x > result:
            break
        b = B[x % M]
        if a != b:
            continue
        result = min(result, x)
        break
if result == INF:
    print(-1)
else:
    print(result)
0