记录编号 | 15252 | 评测结果 | AAAAAAAAAA | ||
---|---|---|---|---|---|
题目名称 | [USACO Mar07] 月度花费 | 最终得分 | 100 | ||
用户昵称 | 是否通过 | 通过 | |||
代码语言 | Pascal | 运行时间 | 0.092 s | ||
提交时间 | 2009-11-11 12:17:33 | 内存使用 | 0.49 MiB | ||
Program expense; Type sc=array [1..100000] of longint; Var s:sc; i,j,k,p:longint; n,m:longint; max,h:longint; z,temp:longint; Begin assign(input,'expense.in'); assign(output,'expense.out'); reset(input); rewrite(output); readln(n,m); max:=0; h:=0; for i:=1 to n do begin readln(s[i]); if s[i]>max then max:=s[i]; h:=h+s[i]; end; i:=max; j:=h; while i<j do begin k:=(i+j) div 2; z:=0; temp:=0; for p:=1 to n do begin temp:=temp+s[p]; if temp>k then begin temp:=s[p]; z:=z+1; end; end; if z<m then j:=k else i:=k+1; end; writeln(j); close(input); close(output); End.