結果

問題 No.1544 [Cherry 2nd Tune C] Synchroscope
ユーザー O2MTO2MT
提出日時 2021-06-11 21:58:21
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 606 bytes
コンパイル時間 292 ms
コンパイル使用メモリ 87,044 KB
実行使用メモリ 149,748 KB
最終ジャッジ日時 2023-08-21 12:22:10
合計ジャッジ時間 14,151 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
149,748 KB
testcase_01 AC 72 ms
71,464 KB
testcase_02 AC 72 ms
71,444 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 282 ms
77,380 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 411 ms
77,420 KB
testcase_25 AC 411 ms
77,428 KB
testcase_26 AC 412 ms
77,524 KB
testcase_27 WA -
testcase_28 AC 896 ms
77,528 KB
testcase_29 AC 648 ms
77,464 KB
testcase_30 WA -
testcase_31 AC 409 ms
77,484 KB
testcase_32 AC 652 ms
77,532 KB
testcase_33 TLE -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
flg = False
p = []
for i in range(N):
  for j in range(M):
    if A[i] == B[j]:
      if not flg:
        p.append([i,j])
        flg = True
      else:
        if abs(i-j) == abs(p[-1][0]-p[-1][1]):
          p.append([i,j])
        elif abs(i-j) < abs(p[-1][0]-p[-1][1]):
          p = [[i,j]]
        else:
          pass
if flg:
  ans = float('inf')
  for a,b in p:
    for n in range(N*M+1):
      m = (N*n+a-b)/M
      if m.is_integer():
        ans = min(ans,N*n+a+1)
  print(ans)
else:
  print(-1)
0