結果

問題 No.2627 Unnatural Pitch
ユーザー Taro TanakaTaro Tanaka
提出日時 2024-02-09 23:00:23
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 643 bytes
コンパイル時間 357 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 108,708 KB
最終ジャッジ日時 2024-09-28 16:10:07
合計ジャッジ時間 3,791 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 6 WA * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import bisect_right

N,K,L,U = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
now_li = 0
now_ui = bisect_right(A,U-L+A[0]) - 1
now_l = A[0]

if now_ui == N-1:
    print(0)
else:
    while now_ui < N-1:
        if A[now_ui+1] - (now_l + U - L) < A[now_li+1] - now_l:
            now_l = A[now_ui+1] - U + L
            now_ui += 1
        else:
            now_l = A[now_li]
            now_li += 1
        if N - 1 - now_ui <= now_li:
            break
    now_u = now_l + U - L
    ans = 0
    for a in A:
        ans += max(now_l - a + K - 1, 0)//K
        ans += max(a - now_u + K - 1, 0)//K
    print(ans)
0