結果

問題 No.1722 [Cherry 3rd Tune C] In my way
ユーザー nariyel
提出日時 2021-10-29 22:39:39
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 623 bytes
コンパイル時間 176 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-10-07 12:18:13
合計ジャッジ時間 1,723 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 15 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

from sys import stdin

N, M = map(int, stdin.readline().split())
X = list(map(int, stdin.readline().split()))
Y = list(map(int, stdin.readline().split()))
Y.sort()
ymax = max(Y)
#print(Y)

def bintan(liste, cle):
    d = len(liste)
    g = -1

    while d - g > 1:
        moy = g + (d - g) // 2
        if liste[moy] >= cle:
            d = moy
        else:
            g = moy
    return d

for hito in X:
    i = bintan(Y, hito)
    if hito >= ymax:
        print("infinity")
    elif i >= M:
        i -= 1
        res = Y[i] - hito
        print("infinity" if res <= 0 else res)
    else:
        print(Y[i] - hito)

0