Problem 2989 --Distribution of books

2989: Distribution of books

"
Time Limit $8$ 秒/Second(s) Memory Limit $512$ 兆字节/Megabyte(s)
提交总数 $0$ 正确数量 $0$
裁判形式 标准裁判/Standard Judge 我的状态 尚未尝试
难度 分类标签
zz6d likes reading very much, so he bought a lot of books. One day, zz6d brought n books to a classroom in school. The books of zz6d is so popular that K students in the classroom want to borrow his books to read. Every book of zz6d has a number i (1<=i<=n). Every student in the classroom wants to get a continuous number books. Every book has a pleasure value, which can be 0 or even negative (causing discomfort). Now zz6d needs to distribute these books to K students. The pleasure value of each student is defined as the sum of the pleasure values of all the books he obtains.Zz6d didn't want his classmates to be too happy, so he wanted to minimize the maximum pleasure of the K classmates. zz6d can hide some last numbered books and not distribute them,which means he can just split the first x books into k parts and ignore the rest books, every part is consecutive and no two parts intersect with each other.However,every classmate must get at least one book.Now he wonders how small can the maximum pleasure of the K classmates be. 

1<=T<=10 
1<=n<=2*105105 
1<=k<=n 
-109109<=aiai<=109
Input contains multiple test cases. 
The first line of the input is a single integer T which is the number of test cases. T test cases follow. 
For each test case, the first line contains two integer n,k: the number of books and the number of his classmates. The second line contains n integers a1a1 ,a2a2,…, an−1an−1,anan. (aiaimeans the pleasure value of book i.)∑∑n<=2*105105
For each case, print the smallest maximum pleasure of the K classmates, and one line one case.
2
4 2
3 -2  4 -2
5 4
-1 -1 -1 -1 6
2
-1
In the first example,classmate 1 get book 1,2, classmate 2 get book 3,4.the maximum pleasure is max((3-2),(4-2))=2;

In the second example,he can ignore book 5 and spilt the first 4 books into 4 parts,give them to his classmates.

推荐代码 查看2989 所有题解 上传题解视频得图灵币

本题记录 用 户(点击查看用户) 运行号(点击购买题解) 时 间
算法最快[$ $ms]
内存最少[$ $KB]
第一AC
第一挑战

赛题来源/所属竞赛 2019 Multi-University Training Contest 3 N/A

竞赛编号 竞赛名称 竞赛时间 访问比赛