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 ...
随机推荐
- 爬虫入门六 总结 资料 与Scrapy实例-bibibili番剧信息
title: 爬虫入门六 总结 资料 与Scrapy实例-bibibili番剧信息 date: 2020-03-16 20:00:00 categories: python tags: crawler ...
- select(),fd_set(),fd_isset()
1. select函数 1. 用途 在编程的过程中,经常会遇到许多阻塞的函数,好像read和网络编程时使用的recv, recvfrom函数都是阻塞的函数,当函数不能成功执行的时候,程序就会一直阻塞在 ...
- 错误记录:MQJE001: 完成代码为 '2',原因为 '2035'。
在windows server 2008上安装websphere mq7.5 服务端,建立队列.通过java client向我的机器的队列发送消息和接收消息. mq安装成功,队列管理器.队列.通道也都 ...
- 探究为什么FreeRTOS 有些API不能在中断服务函数中调用,转而需要调用带ISR的版本
用了好久的FreeRTOS以前只是知道,如果在中断服务程序中调用某一些FreeRTOS的API函数时需要注意,如果有ISR版本的一定要调用末尾带ISR的函数,并且中断服务程序要调用freeRTOS的A ...
- 008.NET5_IIS安装教程
控制面板->程序->启动或关闭Windows功能
- tfrecords转图片存储
import os import shutil import tensorflow as tf import time import sys import cv2 # 图片存放位置 PATH_RES ...
- 使用 js 实现十大排序算法: 归并排序
使用 js 实现十大排序算法: 归并排序 归并排序 refs js 十大排序算法 All In One https://www.cnblogs.com/xgqfrms/p/13947122.html ...
- image cache service
image cache service 图床 https://images.weserv.nl/ https://github.com/weserv/images meta & referre ...
- Android Studio & zh-Hans
Android Studio & zh-Hans https://developer.android.com/studio?hl=zh-cn https://developer.android ...
- infinite auto load more & infinite scroll & load more
infinite auto load more & infinite scroll & load more https://codepen.io/xgqfrms/pen/NZVvGM ...