/* -*- coding: utf-8 -*- * * 3471.cc: No.3471 繧ク繝」繝・ず繧オ繝シ繝舌・縺ョ雋闕キ蛻・淵 - yukicoder */ #include #include #include using namespace std; /* constant */ const int MAX_N = 200000; /* typedef */ using ll = long long; /* global variables */ int ts[MAX_N]; /* subroutines */ /* main */ int main() { int n, m; scanf("%d%d", &n, &m); for (int i = 0; i < n; i++) scanf("%d", ts + i); priority_queue q; for (int i = 0; i < m; i++) q.push(0); for (int i = 0; i < n; i++) { auto qt = q.top(); q.pop(); q.push(qt - ts[i]); } ll maxt = 0; while (! q.empty()) maxt = -q.top(), q.pop(); printf("%lld\n", maxt); return 0; }