当前位置:网站首页>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;
}
边栏推荐
- L2-006 树的遍历 (25 分)
- Image recognition - pyteseract TesseractNotFoundError: tesseract is not installed or it‘s not in your path
- Mtcnn face detection
- Rhcsa certification exam exercise (configured on the first host)
- Kept VRRP script, preemptive delay, VIP unicast details
- What does usart1 mean
- Julia 1.6 1.7 common problem solving
- Test objects involved in safety test
- Codeforces Round #771 (Div. 2)
- Valentine's Day flirting with girls to force a small way, one can learn
猜你喜欢

软件测试与质量学习笔记3--白盒测试

Unable to call numpy in pycharm, with an error modulenotfounderror: no module named 'numpy‘

【yarn】CDP集群 Yarn配置capacity调度器批量分配

wangeditor富文本引用、表格使用问题

小L的试卷

Integration test practice (1) theoretical basis

Introduction and use of automatic machine learning framework (flaml, H2O)

Vs2019 desktop app quick start

Did you forget to register or load this tag

AcWing 1298.曹冲养猪 题解
随机推荐
Word typesetting (subtotal)
【CDH】CDH5.16 配置 yarn 任务集中分配设置不生效问题
Vs2019 first MFC Application
Machine learning -- census data analysis
L2-007 家庭房产 (25 分)
分布式節點免密登錄
QT creator test
[yarn] CDP cluster yarn configuration capacity scheduler batch allocation
【presto】presto 参数配置优化
天梯赛练习集题解LV1(all)
搞笑漫画:程序员的逻辑
How to build a new project for keil5mdk (with super detailed drawings)
L2-004 is this a binary search tree? (25 points)
Image recognition - pyteseract TesseractNotFoundError: tesseract is not installed or it‘s not in your path
数据库高级学习笔记--SQL语句
vs2019 桌面程序快速入门
L2-001 紧急救援 (25 分)
软件测试与质量学习笔记3--白盒测试
Introduction and use of automatic machine learning framework (flaml, H2O)
Error connecting to MySQL database: 2059 - authentication plugin 'caching_ sha2_ The solution of 'password'
