Lang:G++
Edit12345678910111213141516171819202122232425262728293031#include <iostream>using namespace std;typedef long long i64;int n, k;int a[100010];i64 S = 0;bool check(i64 t){int tk = 0;i64 s = 0, _s = 0;for (int i = 1; i <= n; i++){if (s < t)s += a[i];if (s>=t){tk++;s = 0;if (tk == k - 1){for (int j = i+1; j <= n; j++){_s += a[j];}break;}}}