結果

問題 No.1808 Fullgold Alchemist
ユーザー mkawa2mkawa2
提出日時 2022-01-14 21:34:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 176 ms / 2,000 ms
コード長 1,196 bytes
コンパイル時間 178 ms
コンパイル使用メモリ 82,388 KB
実行使用メモリ 124,540 KB
最終ジャッジ日時 2024-04-30 13:00:05
合計ジャッジ時間 4,568 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
53,112 KB
testcase_01 AC 33 ms
53,072 KB
testcase_02 AC 34 ms
52,616 KB
testcase_03 AC 32 ms
52,204 KB
testcase_04 AC 31 ms
52,828 KB
testcase_05 AC 63 ms
96,936 KB
testcase_06 AC 141 ms
124,540 KB
testcase_07 AC 125 ms
106,228 KB
testcase_08 AC 84 ms
98,304 KB
testcase_09 AC 89 ms
98,296 KB
testcase_10 AC 89 ms
98,296 KB
testcase_11 AC 167 ms
114,884 KB
testcase_12 AC 176 ms
117,180 KB
testcase_13 AC 173 ms
116,676 KB
testcase_14 AC 171 ms
117,184 KB
testcase_15 AC 172 ms
117,140 KB
testcase_16 AC 43 ms
64,504 KB
testcase_17 AC 34 ms
53,668 KB
testcase_18 AC 62 ms
80,456 KB
testcase_19 AC 38 ms
62,404 KB
testcase_20 AC 66 ms
86,408 KB
testcase_21 AC 48 ms
69,660 KB
testcase_22 AC 33 ms
53,876 KB
testcase_23 AC 45 ms
67,188 KB
testcase_24 AC 41 ms
62,464 KB
testcase_25 AC 44 ms
64,200 KB
testcase_26 AC 61 ms
81,188 KB
testcase_27 AC 64 ms
83,084 KB
testcase_28 AC 162 ms
122,224 KB
testcase_29 AC 87 ms
93,356 KB
testcase_30 AC 79 ms
87,852 KB
testcase_31 AC 164 ms
113,832 KB
testcase_32 AC 119 ms
95,332 KB
testcase_33 AC 135 ms
105,644 KB
testcase_34 AC 169 ms
110,776 KB
testcase_35 AC 129 ms
100,952 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = 18446744073709551615
# inf = 4294967295
md = 10**9+7
# md = 998244353


n, m = LI()
aa = LI()

def binary_search(l, r, ok, minimize):
    if minimize: l -= 1
    else: r += 1
    while l+1 < r:
        m = (l+r)//2
        if ok(m) ^ minimize: l = m
        else: r = m
    if minimize: return r
    return l

def ok(m):
    s = 0
    for a in aa[::-1]:
        if a > m:
            s = max(0, s-(a-m))
        else:
            s += m-a
    return s == 0

l, r = min(aa), max(aa)
ans = binary_search(l, r, ok, False)
print(ans//m)
0