1 条题解
-
0
#include <bits/stdc++.h> using namespace std; const int N = 5e5 + 10; typedef long long LL; LL a[N]; int n, m; bool check(LL x) { LL s = 0; int tm = 1; for (int i = 1; i <= n; i++) { s += a[i]; while (s >= x) s /= 2, tm++; if (tm > m) return 1; } return 0; } int main() { scanf("%d%d", &n, &m); LL l = 0, r = 0, ans; for (int i = 1; i <= n; i++) scanf("%lld", &a[i]), r += a[i]; while (l <= r) { LL mid = (l + r) / 2; if (check(mid)) l = mid + 1, ans = mid; else r = mid - 1; } printf("%lld\n", ans); return 0; }
- 1
信息
- ID
- 2592
- 时间
- 200ms
- 内存
- 128MiB
- 难度
- 6
- 标签
- 递交数
- 151
- 已通过
- 51
- 上传者