結果

問題 No.1808 Fullgold Alchemist
ユーザー moharan627moharan627
提出日時 2022-01-15 00:41:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 111 ms / 2,000 ms
コード長 1,566 bytes
コンパイル時間 753 ms
コンパイル使用メモリ 82,428 KB
実行使用メモリ 103,560 KB
最終ジャッジ日時 2024-04-30 19:29:05
合計ジャッジ時間 4,451 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
54,196 KB
testcase_01 AC 43 ms
55,356 KB
testcase_02 AC 43 ms
55,052 KB
testcase_03 AC 43 ms
53,944 KB
testcase_04 AC 44 ms
54,788 KB
testcase_05 AC 77 ms
97,376 KB
testcase_06 AC 89 ms
103,560 KB
testcase_07 AC 84 ms
102,244 KB
testcase_08 AC 111 ms
100,540 KB
testcase_09 AC 106 ms
100,516 KB
testcase_10 AC 103 ms
100,772 KB
testcase_11 AC 105 ms
98,800 KB
testcase_12 AC 89 ms
102,440 KB
testcase_13 AC 97 ms
102,192 KB
testcase_14 AC 96 ms
102,880 KB
testcase_15 AC 96 ms
102,472 KB
testcase_16 AC 49 ms
62,036 KB
testcase_17 AC 43 ms
54,972 KB
testcase_18 AC 55 ms
68,152 KB
testcase_19 AC 47 ms
61,844 KB
testcase_20 AC 58 ms
71,596 KB
testcase_21 AC 51 ms
64,764 KB
testcase_22 AC 43 ms
54,512 KB
testcase_23 AC 50 ms
64,048 KB
testcase_24 AC 48 ms
62,412 KB
testcase_25 AC 50 ms
63,408 KB
testcase_26 AC 56 ms
67,516 KB
testcase_27 AC 57 ms
69,964 KB
testcase_28 AC 103 ms
97,644 KB
testcase_29 AC 62 ms
74,956 KB
testcase_30 AC 60 ms
74,308 KB
testcase_31 AC 91 ms
97,536 KB
testcase_32 AC 74 ms
84,164 KB
testcase_33 AC 84 ms
92,612 KB
testcase_34 AC 104 ms
97,668 KB
testcase_35 AC 81 ms
89,732 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
#sys.setrecursionlimit(10 ** 6)
INF = float('inf')
#10**20,2**63に変えるのもあり
MOD = 10**9 + 7
MOD2 = 998244353
from collections import defaultdict
def solve():
    def II(): return int(sys.stdin.readline())
    def LI(): return list(map(int, sys.stdin.readline().split()))
    def LC(): return list(input())
    def IC(): return [int(c) for c in input()]
    def MI(): return map(int, sys.stdin.readline().split())
    N,M = MI()
    A = LI()

    def is_ok(arg):
        # 条件を満たすかどうか?問題ごとに定義
        OK = True
        Rest = 0
        for n in range(N):
            if arg*M > A[n]+Rest:
                OK = False
                break
            else:
                Rest = A[n] + Rest - arg*M
        return OK

    def meguru_bisect(ng, ok):
        """
        この条件は、問題に基づくやつじゃなくてもOK
        条件の付け方は、ngとokの広げ方をどのようにするかで決まってくる。

        負の無限~(目的値)が条件を満たす場合
        ng…条件を満たさない値の範囲での最小値
        ok…条件を満たす値の範囲での最大値
        ok < ng
        is_ok == Trueの場合、探索範囲が右半分へ
        is_ok == Falseの場合、探索範囲が左半分へ
        """
        while (abs(ok - ng) > 1):
            mid = (ok + ng) // 2
            if is_ok(mid):
                ok = mid
            else:
                ng = mid
        return ok
    print(meguru_bisect(10**10,0))
    return
solve()
0