結果

問題 No.2217 Suffix+
ユーザー タコイモタコイモ
提出日時 2023-02-17 21:32:45
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 238 ms / 2,000 ms
コード長 1,385 bytes
コンパイル時間 309 ms
コンパイル使用メモリ 87,120 KB
実行使用メモリ 93,532 KB
最終ジャッジ日時 2023-09-26 18:42:52
合計ジャッジ時間 6,640 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
71,524 KB
testcase_01 AC 92 ms
71,200 KB
testcase_02 AC 92 ms
71,380 KB
testcase_03 AC 92 ms
71,304 KB
testcase_04 AC 92 ms
71,660 KB
testcase_05 AC 92 ms
71,300 KB
testcase_06 AC 92 ms
71,304 KB
testcase_07 AC 95 ms
71,524 KB
testcase_08 AC 92 ms
71,592 KB
testcase_09 AC 91 ms
71,524 KB
testcase_10 AC 92 ms
71,300 KB
testcase_11 AC 92 ms
71,436 KB
testcase_12 AC 93 ms
71,464 KB
testcase_13 AC 93 ms
71,656 KB
testcase_14 AC 104 ms
79,228 KB
testcase_15 AC 107 ms
79,160 KB
testcase_16 AC 115 ms
84,028 KB
testcase_17 AC 110 ms
81,360 KB
testcase_18 AC 107 ms
80,336 KB
testcase_19 AC 146 ms
87,932 KB
testcase_20 AC 149 ms
86,200 KB
testcase_21 AC 106 ms
76,980 KB
testcase_22 AC 140 ms
88,264 KB
testcase_23 AC 142 ms
83,976 KB
testcase_24 AC 133 ms
93,252 KB
testcase_25 AC 131 ms
93,188 KB
testcase_26 AC 130 ms
93,372 KB
testcase_27 AC 130 ms
93,376 KB
testcase_28 AC 131 ms
93,532 KB
testcase_29 AC 207 ms
93,192 KB
testcase_30 AC 208 ms
93,240 KB
testcase_31 AC 208 ms
93,276 KB
testcase_32 AC 209 ms
93,224 KB
testcase_33 AC 210 ms
93,272 KB
testcase_34 AC 137 ms
93,416 KB
testcase_35 AC 94 ms
71,196 KB
testcase_36 AC 238 ms
93,068 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
#sys.setrecursionlimit(500000)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def TI(): return tuple(map(int,sys.stdin.readline().rstrip().split()))
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip())
#for i, pi in enumerate(p):
from collections import defaultdict,deque
import bisect
import itertools
dic = defaultdict(int)
d = deque()
YN = ['No','Yes']

N,K = MI()
A = LI()
#https://aotamasaki.hatenablog.com/entry/meguru_bisect
def is_ok(arg):
  count = 0
  plus = 0
  for i in range(1,N+1):
    ap = A[i-1]+plus
    if ap < arg:
      h = (arg-ap+i-1)//i
      count += h
      if count > K:
        return False
      plus += h*i
  if count <= K:
    return True
  else:
    return False
      
    

def meguru_bisect(ng, ok):
    '''
    初期値のng,okを受け取り,is_okを満たす最小(最大)のokを返す
    まずis_okを定義すべし
    ng ok は  とり得る最小の値-1 とり得る最大の値+1
    最大最小が逆の場合はよしなにひっくり返す
    '''
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return ok
print(meguru_bisect(10**14+10**10,0))
0