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 ...
随机推荐
- spring再学习之基本概念
二.spring之IOC与DI 注入的方式: set方法注入: 构造方法注入: 字段注入: 注入类型: 值类型注入:8中基本类型 引用类型注入: BeanFaactory是原始接口:功能比较单一. A ...
- Gitlab 快速部署及日常维护 (二)
一.概述 上一篇我们将Gitlab的安装部署和初始化设置部分全部讲解完成了,接下来我们介绍Gitlab在日常工作中常遇见的问题进行梳理说明. 二.Gitlab的安装和维护过程中常见问题 1.Gitla ...
- 从 MFC 移植程序到 wxWidgets 界面库 ——《定时执行专家 5.0》的界面实现
时隔十年的更新,最大的变化就是从 MFC 移植到 wxWidgets,界面也全部重现设计,图标也都进行了更换.wxWidgets(最新版 3.1.4,经典的开源.跨平台 C++ GUI类库)特有的 ...
- C++的继承权限
原文来自于:https://www.cnblogs.com/2018shawn/p/10648408.html 公式: 继承成员对外的访问属性 = Max{继承方式,父类成员访问级别}: ps;以下成 ...
- 解决debian (Friendly ARM 嵌入式板)的sudo等一部分命令无法TAB补全
TAB对于比较长的命令在使用时是十分方便的,最近就遇到TAB 键无法补全sudo后跟的命令的情况因此去网上取经.在一篇博客中找到解决问题的方法,觉得大牛们写的太精炼然后自己做如下总结方便自已以后解决类 ...
- JWT All In One
JWT All In One OAuth 2.0 JWT JSON Web Tokens https://jwt.io refs https://www.cnblogs.com/xgqfrms/tag ...
- docthis & VS code
docthis & VS code JSDoc 3 http://usejsdoc.org/ http://usejsdoc.org/about-getting-started.html ht ...
- yarn global add !== yarn add global
yarn global add !== yarn add global yarn does not exist the --global flag, but exits yarn global com ...
- MySQL 8.x
MySQL 8.x SQL & NoSQL $ mysql --version # mysql Ver 8.0.21 for osx10.15 on x86_64 (Homebrew) # M ...
- Azure & Serverless
Azure & Serverless https://azure.microsoft.com/en-us/get-started/webinar/on-demand/ blob:https:/ ...