結果

問題 No.2217 Suffix+
ユーザー 👑 obakyanobakyan
提出日時 2023-02-17 23:45:10
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 401 ms / 2,000 ms
コード長 638 bytes
コンパイル時間 251 ms
コンパイル使用メモリ 5,296 KB
実行使用メモリ 11,868 KB
最終ジャッジ日時 2023-09-26 21:06:39
合計ジャッジ時間 5,242 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,384 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 13 ms
4,376 KB
testcase_15 AC 13 ms
4,380 KB
testcase_16 AC 24 ms
4,536 KB
testcase_17 AC 18 ms
4,380 KB
testcase_18 AC 14 ms
4,376 KB
testcase_19 AC 140 ms
10,516 KB
testcase_20 AC 126 ms
9,740 KB
testcase_21 AC 11 ms
4,380 KB
testcase_22 AC 97 ms
10,184 KB
testcase_23 AC 126 ms
7,304 KB
testcase_24 AC 48 ms
6,444 KB
testcase_25 AC 48 ms
6,424 KB
testcase_26 AC 47 ms
6,452 KB
testcase_27 AC 48 ms
6,284 KB
testcase_28 AC 48 ms
6,296 KB
testcase_29 AC 395 ms
11,776 KB
testcase_30 AC 398 ms
11,868 KB
testcase_31 AC 401 ms
11,828 KB
testcase_32 AC 390 ms
11,784 KB
testcase_33 AC 394 ms
11,764 KB
testcase_34 AC 49 ms
6,332 KB
testcase_35 AC 2 ms
4,376 KB
testcase_36 AC 133 ms
6,360 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

local n, k = io.read("*n", "*n")
k = 1LL * k
local a = {}
for i = 1, n do
  a[i] = 1LL * io.read("*n")
end

local function solve(x)
  local cnt = 0LL
  local sum = 0LL
  for i = 1, n do
    if sum + a[i] < x then
      local needadd = (x - sum - a[i] + i - 1LL) / (1LL * i)
      cnt = cnt + needadd
      if k < cnt then return false end
      sum = sum + needadd * i
    end
  end
  -- print(x, cnt)
  return true
end

local min, max = 0LL, 1LL * 1000000007 * 200000
while 1LL < max - min do
  local mid = (min + max) / 2LL
  if solve(mid) then
    min = mid
  else
    max = mid
  end
end
min = tostring(min):gsub("LL", "")
print(min)
0