/* -*- coding: utf-8 -*- * * 2217.cc: No.2217 Suffix+ - yukicoder */ #include #include using namespace std; /* constant */ const int MAX_N = 100000; /* typedef */ typedef long long ll; /* global variables */ ll as[MAX_N]; /* subroutines */ ll check(int n, ll x) { ll c = 0, s = 0; for (int i = 0; i < n; i++) if (x > as[i] + s) { ll d = (x - (as[i] + s) + i) / (i + 1); c += d; s += d * (i + 1); } return c; } /* main */ int main() { int n, k; scanf("%d%d", &n, &k); for (int i = 0; i < n; i++) scanf("%lld", as + i); ll x0 = 0, x1 = 200000000000000LL + 1; while (x0 + 1 < x1) { ll x = (x0 + x1) / 2; if (check(n, x) > k) x1 = x; else x0 = x; } printf("%lld\n", x0); return 0; }