結果
| 問題 |
No.1544 [Cherry 2nd Tune C] Synchroscope
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-06-11 23:24:24 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 395 bytes |
| コンパイル時間 | 319 ms |
| コンパイル使用メモリ | 82,248 KB |
| 実行使用メモリ | 131,604 KB |
| 最終ジャッジ日時 | 2024-12-15 02:45:28 |
| 合計ジャッジ時間 | 9,636 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 43 WA * 4 TLE * 1 |
ソースコード
N,M = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
flg = False
ans = float('inf')
for i in range(N):
for j in range(M):
if A[i] == B[j]:
num = 0
while num <= min(N,M):
if (num*N+i-j)%M == 0:
flg = True
ans = min(ans,num*N+i+1)
break
num += 1
if flg:
print(ans)
else:
print(-1)