Monthly Expense, monthlyexpense
Problem Description
Farmer John is an astounding accounting wizard and has realized he might run out of money to run the farm. He has already calculated and recorded the exact amount of money (1 ≤Moneyi≤ 10,000) that he will need to spend each day over the nextN(1 ≤N≤ 100,000) days.
FJ wants to create a budget for a sequential set of exactlyM(1 ≤M≤N) Fiscal periods called "fajomonths". Each of these fajomonths contains a set of 1 or more consecutive days. Every day is contained in exactly one fajomonth.
FJ's goal is to arrange the fajomonths so as to minimize the expenses of the fajomonth with the highest spending and thus determine his monthly spending limit.
InputLine 1: Two space-separated integers:
NAnd
M
Lines 2 ..
N+ 1: Line
I+ 1 contains the number of dollars Farmer John sort Ds on
ITh day
OutputLine 1: The smallest possible monthly limit Farmer John can afford to live.
Sample Input
7 5100400300100500101400
Sample Output
500
# Include <iostream> # include <cstdio> using namespace std; int n, m; int a [100010]; int fun (int s) // The fun function is used to determine whether the current mid value can divide n into several groups {// optimize the mid value int sum = 0 by comparing the size of q and m, q = 1; for (int I = 1; I <= n; I ++) // traverse the daily spending from the first day to the next {if (sum + a [I] <= s) // The first day and <= mid, classify them into this group sum + = a [I]; else // otherwise, the day I serves as the first day of the next group {sum = a [I]; q ++; // number of groups plus one }}if (q> m) // if the number of groups is greater than m, it indicates that the value of mid is smaller, return 0; return 1; // otherwise it is larger} int main () {while (~ Scanf ("% d", & n, & m) {int l, r = 0, mid, min = 0, sum = 0; for (int I = 1; I <= n; I ++) {scanf ("% d", & a [I]); sum + = a [I]; if (a [I]> r) r = a [I];} l = sum; int ans = 0; mid = (l + r)/2; while (r <l) {if (! Fun (mid) // If the mid is too small {r = mid + 1; // the lower bound is increased} else // otherwise {l = mid-1; // lower upper bound} mid = (r + l)/2;} cout <mid <endl;} return 0 ;}
His monthly expense _________ 350 dollars
Select C
A. As "total is", total should be removed from
B. amount, as "Total", is an inactive verb used with to instead of
D. account and for can be used together to indicate "count in quantity ..." Example: Children accounts for 12% of the US population.
Expend expense
Spending; spending
Expend is a verb and the meaning of spending. expense is a noun and also a meaning of spending,