Question: Give You n m and then give you n numbers. Let you divide the n numbers into m parts, and each part is continuous. Ask the minimum value of the maximum value in all parts. Practice: binary. At the beginning, the previous session was the sum of n numbers. Indicates that only one group is allowed. The next session is the maximum number of n numbers. Indicates that the Group is divided into n groups. If the result is mid = (previous + next)/2, you can check the number of groups that can be divided by mid. If the number of groups is greater than m, the value of mid is smaller than the actual value. The next session becomes mid + 1. Otherwise, the previous session becomes mid-1; [html] # include <iostream> # include <stdio. h> # include <string. h> using namespace std; int a [100100]; int n, m; int sw (int mid) {int s, num, I; s = 0; num = 1; for (I = 0; I <n; I ++) {if (s + a [I] <= mid) {s + = a [I];} else {s = a [I]; num ++ ;}} if (num> m) return 1; else return 0 ;}int main () {int l, r, i, mid; cin> n> m; r = 0; l = 0; for (I = 0; I <n; I ++) {scanf ("% d", & a [I]); r + = a [I]; if (a [I]> l) l = a [I];} mid = (l + r)/2; while (l <r) {www.2cto.com if (sw (mid) l = mid + 1; else r = mid-1; mid = (l + r)/2;} cout <mid <endl; return 0 ;}