当前位置:网站首页>小L的试卷
小L的试卷
2022-07-06 09:14:00 【极客云曦】
题目描述
小L期末考试结束,高高兴兴放假回家了,可是那么多试卷,老师还要加班批改,有n份试卷由k个老师批改,n份试卷进行了密封编号,由于试卷上的做题情况和书写的规范程序不一样,批改不同的试卷用时也可能不一样,每个老师批改试卷的编号顺序是连续的,每位老师批改完分配给自己的试卷就可以离开,问最后离开的老师,最短可能的用时是多少,假定一份试卷让任何一位老师批改用时都是一样的。现在请你设计一种分配方案,使得最后离开的老师用时最短。
输入
第一行两个整数n,k;(0<k≤n≤1000)
第二行n个整数,第i个整数表示批改第i份试卷的用时。
输出
输出一个整数,表示最后离开的老师所用的最短时间
样例输入 Copy
9 3
1 2 3 4 5 6 7 8 9样例输出 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;
}
边栏推荐
- Why can't STM32 download the program
- When using lambda to pass parameters in a loop, the parameters are always the same value
- [蓝桥杯2021初赛] 砝码称重
- Learn winpwn (3) -- sEH from scratch
- Tcp/ip protocol (UDP)
- About string immutability
- MySQL and C language connection (vs2019 version)
- Basic use of redis
- Deoldify project problem - omp:error 15:initializing libiomp5md dll,but found libiomp5md. dll already initialized.
- Principes JDBC
猜你喜欢

图片上色项目 —— Deoldify
![[free setup] asp Net online course selection system design and Implementation (source code +lunwen)](/img/ac/b518796a92d00615cd374c0c835f38.jpg)
[free setup] asp Net online course selection system design and Implementation (source code +lunwen)

Django running error: error loading mysqldb module solution

Classes in C #

Cookie setting three-day secret free login (run tutorial)
![[蓝桥杯2017初赛]方格分割](/img/e9/e49556d0867840148a60ff4906f78e.png)
[蓝桥杯2017初赛]方格分割

Windows下安装MongDB教程、Redis教程

Leetcode 461 Hamming distance

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

QT creator shape
随机推荐
Learning question 1:127.0.0.1 refused our visit
自动机器学习框架介绍与使用(flaml、h2o)
L2-006 树的遍历 (25 分)
UDS learning notes on fault codes (0x19 and 0x14 services)
天梯赛练习集题解LV1(all)
ImportError: libmysqlclient. so. 20: Cannot open shared object file: no such file or directory solution
vs2019 桌面程序快速入门
DICOM: Overview
误删Path变量解决
QT creator shape
Machine learning notes week02 convolutional neural network
How to configure flymcu (STM32 serial port download software) is shown in super detail
PHP - whether the setting error displays -php xxx When PHP executes, there is no code exception prompt
yarn安装与使用
Introduction to the easy copy module
PyCharm中无法调用numpy,报错ModuleNotFoundError: No module named ‘numpy‘
Nanny level problem setting tutorial
Django running error: error loading mysqldb module solution
One click extraction of tables in PDF
图片上色项目 —— Deoldify
