2019 GDUT Rating Contest I : Problem E. Convention
题面:
E. Convention
题目描述:
题目分析:
1 #include <cstdio>
2 #include <cstring>
3 #include <iostream>
4 #include <cmath>
5 #include <set>
6 #include <algorithm>
7 using namespace std;
8 const int maxn = 1e5+5;
9 int n, m, c;
10 long long a[maxn];
11
12 bool check(int t){
13 int all = m; //车的数量
14 int p = 0;
15 while(p < n){
16 int k = p;
17 int d = c; //车的装载量
18 while(a[k]-a[p] <= t && d && k < n){
19 d--, k++;
20 }
21 p = k;
22 all--;
23 }
24 if(all >= 0) return true; //车够用就返回true
25 else return false;
26 }
27
28 int main(){
29 cin >> n >> m >> c;
30 for(int i = 0; i < n; i++) cin >> a[i];
31 sort(a, a+n);
32
33 int l = -1, r = 1e9;
34 int mid;
35 while(l < r){
36 mid = (l+r)/2; //左开右闭向下取整
37 if(check(mid)){
38 r = mid;
39 }
40 else l = mid+1;
41 }
42 cout << l << endl;
43 return 0;
44 }
2019 GDUT Rating Contest I : Problem E. Convention的更多相关文章
- 2019 GDUT Rating Contest II : Problem F. Teleportation
题面: Problem F. Teleportation Input file: standard input Output file: standard output Time limit: 15 se ...
- 2019 GDUT Rating Contest III : Problem D. Lemonade Line
题面: D. Lemonade Line Input file: standard input Output file: standard output Time limit: 1 second Memo ...
- 2019 GDUT Rating Contest I : Problem H. Mixing Milk
题面: H. Mixing Milk Input file: standard input Output file: standard output Time limit: 1 second Memory ...
- 2019 GDUT Rating Contest I : Problem A. The Bucket List
题面: A. The Bucket List Input file: standard input Output file: standard output Time limit: 1 second Me ...
- 2019 GDUT Rating Contest I : Problem G. Back and Forth
题面: G. Back and Forth Input file: standard input Output file: standard output Time limit: 1 second Mem ...
- 2019 GDUT Rating Contest III : Problem E. Family Tree
题面: E. Family Tree Input file: standard input Output file: standard output Time limit: 1 second Memory ...
- 2019 GDUT Rating Contest III : Problem C. Team Tic Tac Toe
题面: C. Team Tic Tac Toe Input file: standard input Output file: standard output Time limit: 1 second M ...
- 2019 GDUT Rating Contest III : Problem A. Out of Sorts
题面: 传送门 A. Out of Sorts Input file: standard input Output file: standard output Time limit: 1 second M ...
- 2019 GDUT Rating Contest II : Problem G. Snow Boots
题面: G. Snow Boots Input file: standard input Output file: standard output Time limit: 1 second Memory ...
随机推荐
- Java中多线程启动,为什么调用的是start方法,而不是run方法?
前言 大年初二,大家新年快乐,我又开始码字了.写这篇文章,源于在家和基友交流的时候,基友问到了,我猛然发现还真是这么回事,多线程启动调用的都是start,那么为什么没人掉用run呢?于是打开我的ide ...
- HDU 4511 小明系列故事——女友的考验 (AC自动机 + DP)题解
题意:从 1 走到 n,要求所走路径不能出现给定的路径,求最短路 思路:因为要求不能出现给定路径,那么我可以求助ac自动机完成判断. 我们可以在build的时候标记哪些路径不能出现,显然下面这种表示后 ...
- 洛谷p1981 表达式求值
#include <iostream> #include <cstdio> #include <cstring> using namespace std; char ...
- google 人机身份验证
google 人机身份验证 Are you a robot? Introducing "No CAPTCHA reCAPTCHA" https://googleonlinesecu ...
- TypeScript enum 枚举实现原理
TypeScript enum 枚举实现原理 反向映射 https://www.typescriptlang.org/docs/handbook/enums.html enum Direction { ...
- redux 中间件 redux-saga 使用教程
redux 中间件 redux-saga 使用教程 redux middleware refs https://redux-saga.js.org/docs/ExternalResources.htm ...
- style element & web components
style element & web components style.textContent style.setContent bug style.textContent const st ...
- Objective C & Swift & iOS & App
Objective C & Swift & iOS & App https://www.runoob.com/ios/ios-objective-c.html https:// ...
- html fragment & html template & virtual DOM & web components
html fragment & html template & virtual DOM https://developer.mozilla.org/en-US/docs/Web/API ...
- PAUL ADAMS ARCHITECT:薪资追不上房价美一半家庭难买房
尽管上一年度美国经济遭受重创,但美国房价依旧持续蹿扬,据最新调查显示,美国大部分地区的房价已经到了一般家庭无法负担的水准. 美国房价上涨持续强劲,主要受益美国人居家办公需求(受大环境影响,目前美国有7 ...