当前位置:网站首页>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 9
Sample 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;
}
边栏推荐
- L2-004 这是二叉搜索树吗? (25 分)
- ImportError: libmysqlclient. so. 20: Cannot open shared object file: no such file or directory solution
- [Flink] Flink learning
- Codeforces Round #753 (Div. 3)
- Valentine's Day flirting with girls to force a small way, one can learn
- QT creator runs the Valgrind tool on external applications
- [Presto] Presto parameter configuration optimization
- AcWing 242. A simple integer problem (tree array + difference)
- 搞笑漫画:程序员的逻辑
- Machine learning notes week02 convolutional neural network
猜你喜欢
QT creator runs the Valgrind tool on external applications
快来走进JVM吧
In the era of DFI dividends, can TGP become a new benchmark for future DFI?
Software testing and quality learning notes 3 -- white box testing
Reading BMP file with C language
【CDH】CDH5.16 配置 yarn 任务集中分配设置不生效问题
Rhcsa certification exam exercise (configured on the first host)
[Blue Bridge Cup 2017 preliminary] grid division
Image recognition - pyteseract TesseractNotFoundError: tesseract is not installed or it‘s not in your path
Learn winpwn (2) -- GS protection from scratch
随机推荐
ES6 let and const commands
PHP - whether the setting error displays -php xxx When PHP executes, there is no code exception prompt
Password free login of distributed nodes
QT creator test
学习问题1:127.0.0.1拒绝了我们的访问
[蓝桥杯2020初赛] 平面切分
MySQL与c语言连接(vs2019版)
AcWing 1298. Solution to Cao Chong's pig raising problem
【Flink】CDH/CDP Flink on Yarn 日志配置
Base de données Advanced Learning Notes - - SQL statements
Software testing - interview question sharing
2020网鼎杯_朱雀组_Web_nmap
{one week summary} take you into the ocean of JS knowledge
数据库面试常问的一些概念
[Blue Bridge Cup 2017 preliminary] buns make up
L2-001 紧急救援 (25 分)
【CDH】CDH/CDP 环境修改 cloudera manager默认端口7180
Are you monitored by the company for sending resumes and logging in to job search websites? Deeply convinced that the product of "behavior awareness system ba" has not been retrieved on the official w
天梯赛练习集题解LV1(all)
AI benchmark V5 ranking