結果

問題 No.1808 Fullgold Alchemist
ユーザー SidewaysOwl
提出日時 2022-01-14 21:43:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 125 ms / 2,000 ms
コード長 481 bytes
コンパイル時間 342 ms
コンパイル使用メモリ 82,688 KB
実行使用メモリ 104,576 KB
最終ジャッジ日時 2024-11-20 09:03:45
合計ジャッジ時間 4,318 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m = map(int,input().split())
a = list(map(int,input().split()))
sum_ = sum(a)

def ok(s):
    tame = 0
    res = True
    for i in range(n):
        if a[i] < s:
            if tame + a[i] < s:
                res = False
                break
            else:
                tame -= s-a[i]
        else:
            tame += a[i] - s
    return res
l = -1
r = 10 ** 9 + 1
while r-l>1:
    mid = (l + r) // 2
    if ok(mid):
        l = mid
    else:
        r = mid
print(l//m)
0