当前位置:网站首页>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;
}
边栏推荐
- 牛客Novice月赛40
- Error connecting to MySQL database: 2059 - authentication plugin 'caching_ sha2_ The solution of 'password'
- Learn winpwn (3) -- sEH from scratch
- Vs2019 first MFC Application
- Rhcsa certification exam exercise (configured on the first host)
- Codeforces Round #753 (Div. 3)
- SQL time injection
- 數據庫高級學習筆記--SQL語句
- 解决安装Failed building wheel for pillow
- MongoDB
猜你喜欢
Knowledge Q & A based on Apache Jena
AI benchmark V5 ranking
[蓝桥杯2017初赛]方格分割
第4阶段 Mysql数据库
error C4996: ‘strcpy‘: This function or variable may be unsafe. Consider using strcpy_s instead
2019腾讯暑期实习生正式笔试
Machine learning -- census data analysis
Error connecting to MySQL database: 2059 - authentication plugin 'caching_ sha2_ The solution of 'password'
Django running error: error loading mysqldb module solution
Kept VRRP script, preemptive delay, VIP unicast details
随机推荐
Tcp/ip protocol (UDP)
【kerberos】深入理解kerberos票据生命周期
L2-001 emergency rescue (25 points)
Vs2019 first MFC Application
[BSidesCF_2020]Had_a_bad_day
L2-004 is this a binary search tree? (25 points)
[Bluebridge cup 2021 preliminary] weight weighing
[AGC009D]Uninity
[yarn] CDP cluster yarn configuration capacity scheduler batch allocation
Aborted connection 1055898 to db:
02 staff information management after the actual project
Word typesetting (subtotal)
C语言读取BMP文件
[Blue Bridge Cup 2017 preliminary] buns make up
Base de données Advanced Learning Notes - - SQL statements
2020 WANGDING cup_ Rosefinch formation_ Web_ nmap
[Flink] Flink learning
Learning question 1:127.0.0.1 refused our visit
Machine learning notes week02 convolutional neural network
Deoldify project problem - omp:error 15:initializing libiomp5md dll,but found libiomp5md. dll already initialized.