結果

問題 No.1808 Fullgold Alchemist
ユーザー mkawa2mkawa2
提出日時 2022-01-14 21:34:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 228 ms / 2,000 ms
コード長 1,196 bytes
コンパイル時間 285 ms
コンパイル使用メモリ 87,200 KB
実行使用メモリ 140,628 KB
最終ジャッジ日時 2023-08-12 17:53:20
合計ジャッジ時間 6,990 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,296 KB
testcase_01 AC 77 ms
71,496 KB
testcase_02 AC 74 ms
71,496 KB
testcase_03 AC 72 ms
71,312 KB
testcase_04 AC 75 ms
71,564 KB
testcase_05 AC 105 ms
103,540 KB
testcase_06 AC 203 ms
125,668 KB
testcase_07 AC 180 ms
107,096 KB
testcase_08 AC 126 ms
101,572 KB
testcase_09 AC 125 ms
101,472 KB
testcase_10 AC 126 ms
101,364 KB
testcase_11 AC 210 ms
114,020 KB
testcase_12 AC 215 ms
114,912 KB
testcase_13 AC 226 ms
127,384 KB
testcase_14 AC 224 ms
117,920 KB
testcase_15 AC 228 ms
116,476 KB
testcase_16 AC 83 ms
75,876 KB
testcase_17 AC 74 ms
71,280 KB
testcase_18 AC 104 ms
86,804 KB
testcase_19 AC 79 ms
76,124 KB
testcase_20 AC 109 ms
92,196 KB
testcase_21 AC 87 ms
80,584 KB
testcase_22 AC 75 ms
71,080 KB
testcase_23 AC 84 ms
76,216 KB
testcase_24 AC 80 ms
76,224 KB
testcase_25 AC 83 ms
76,196 KB
testcase_26 AC 101 ms
84,820 KB
testcase_27 AC 107 ms
88,308 KB
testcase_28 AC 226 ms
140,628 KB
testcase_29 AC 124 ms
91,924 KB
testcase_30 AC 118 ms
87,600 KB
testcase_31 AC 204 ms
114,996 KB
testcase_32 AC 159 ms
97,716 KB
testcase_33 AC 181 ms
108,404 KB
testcase_34 AC 224 ms
125,732 KB
testcase_35 AC 176 ms
105,248 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