当前位置:网站首页>Small L's test paper
Small L's test paper
2022-07-06 11:37:00 【Geek Yunxi】
Title Description
Small L The final exam is over , Happy holiday home , But so many papers , The teacher has to work overtime to correct , Yes n This paper consists of k A teacher corrects ,n The papers were sealed and numbered , Due to the difference between the standard procedure of writing and the situation of making questions on the test paper , It may take different time to correct different test papers , The numbering sequence of each teacher's correcting papers is continuous , Each teacher can leave after correcting the assigned test paper , Ask the teacher who left last , What is the shortest possible time , Suppose that when any teacher corrects an exam paper, it is the same . Now please design a distribution scheme , Make the last teacher to leave the shortest time .
Input
The first line has two integers n,k;(0<k≤n≤1000)
The second line n It's an integer , The first i An integer indicates the correction number i Time of examination papers .
Output
Output an integer , It means the shortest time for the last teacher to leave
The sample input Copy
9 3
1 2 3 4 5 6 7 8 9Sample output Copy
17

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 0x3f3f3f3f;
const int maxn = 1e5 + 10;
int n , k;
ll a[maxn];
bool isok(int x)
{
bool flag = false;
int num = 0;
ll temp = 0;
for (int i=1; i<=n; i++)
{
if (a[i] > x) return false;
temp += a[i];
if (temp > x)
{
num ++;
temp = a[i];
}
}
if (temp > 0) num ++;
if (num <= k) return true;
else return false;
}
int main()
{
scanf("%d%d", &n, &k);
for (int i=1; i<=n; i++) scanf("%lld", &a[i]);
ll l = 0 , r = inf;
while (l <= r)
{
int mid = (l + r) / 2;
if (isok(mid)) r = mid-1;
else l = mid + 1;
}
cout << l << endl;
return 0;
}
边栏推荐
猜你喜欢

AI benchmark V5 ranking

小L的试卷

QT creator runs the Valgrind tool on external applications

{one week summary} take you into the ocean of JS knowledge

Word排版(小計)

Solve the problem of installing failed building wheel for pilot

MongoDB

QT creator support platform

Machine learning -- census data analysis

Request object and response object analysis
随机推荐
02 staff information management after the actual project
In the era of DFI dividends, can TGP become a new benchmark for future DFI?
When using lambda to pass parameters in a loop, the parameters are always the same value
Punctual atom stm32f103zet6 download serial port pin
Tcp/ip protocol (UDP)
Integration test practice (1) theoretical basis
分布式節點免密登錄
DICOM: Overview
[CDH] cdh5.16 configuring the setting of yarn task centralized allocation does not take effect
[Blue Bridge Cup 2017 preliminary] buns make up
AcWing 179.阶乘分解 题解
[NPUCTF2020]ReadlezPHP
AcWing 1294. Cherry Blossom explanation
小L的试卷
Solution to the practice set of ladder race LV1 (all)
Database advanced learning notes -- SQL statement
快来走进JVM吧
Pytorch基础
ES6 let and const commands
Heating data in data lake?
