結果

問題 No.1544 [Cherry 2nd Tune C] Synchroscope
ユーザー O2MTO2MT
提出日時 2021-06-11 23:09:11
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,100 bytes
コンパイル時間 408 ms
コンパイル使用メモリ 87,052 KB
実行使用メモリ 81,520 KB
最終ジャッジ日時 2023-08-21 14:00:56
合計ジャッジ時間 8,996 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
75,752 KB
testcase_01 AC 68 ms
71,328 KB
testcase_02 AC 73 ms
71,260 KB
testcase_03 AC 115 ms
77,092 KB
testcase_04 AC 125 ms
76,716 KB
testcase_05 AC 114 ms
76,964 KB
testcase_06 AC 118 ms
77,104 KB
testcase_07 AC 120 ms
76,612 KB
testcase_08 AC 105 ms
76,884 KB
testcase_09 AC 85 ms
76,896 KB
testcase_10 AC 124 ms
76,960 KB
testcase_11 AC 110 ms
76,692 KB
testcase_12 AC 101 ms
76,792 KB
testcase_13 AC 80 ms
76,512 KB
testcase_14 AC 139 ms
76,608 KB
testcase_15 AC 145 ms
76,776 KB
testcase_16 AC 103 ms
76,728 KB
testcase_17 AC 97 ms
76,696 KB
testcase_18 AC 79 ms
76,868 KB
testcase_19 AC 84 ms
76,676 KB
testcase_20 AC 136 ms
76,800 KB
testcase_21 AC 94 ms
76,568 KB
testcase_22 AC 81 ms
76,676 KB
testcase_23 AC 157 ms
76,744 KB
testcase_24 AC 165 ms
76,596 KB
testcase_25 AC 166 ms
76,696 KB
testcase_26 AC 164 ms
76,536 KB
testcase_27 AC 169 ms
77,056 KB
testcase_28 AC 169 ms
76,692 KB
testcase_29 AC 164 ms
76,644 KB
testcase_30 AC 164 ms
76,600 KB
testcase_31 AC 169 ms
76,724 KB
testcase_32 AC 170 ms
76,956 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 #

def is_ok(x, a, b):
    # 条件を満たすかどうか?問題ごとに定義
    f = False
    num = (abs(N-M)*x+a-b)/M
    if num.is_integer():
      f = True
    return f


def meguru_bisect(ng, ok, a, b):
    '''
    初期値のng,okを受け取り,is_okを満たす最小(最大)のokを返す
    まずis_okを定義すべし
    ng ok は  とり得る最小の値-1 とり得る最大の値+1
    最大最小が逆の場合はよしなにひっくり返す
    '''
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid, a, b):
            ok = mid
        else:
            ng = mid
    return ok
N,M = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
flg = False
p = []
ans = float('inf')
for i in range(N):
  for j in range(M):
    if A[i] == B[j]:
      flg = True
      num = 0
      while num*N+i+1 < N*M+1:
        if num*N+i+1 >= ans:
          break
        m = (num*N+i-j)/M
        if m.is_integer():
          break
        num += 1
      ans = min(ans,num*N+i+1)

if flg:
  print(ans)
else:
  print(-1)
0