2019 GDUT Rating Contest III : Problem D. Lemonade Line
题面:
D. Lemonade Line
Farmer John wants to prepare some amount of lemonade in advance, but he does not want to be wasteful. The number of cows who join the line might depend on the order in which they arrive. Help him find the minimum possible number of cows who join the line.
题目描述:
题目分析:







1 #include <cstdio>
2 #include <cstring>
3 #include <iostream>
4 using namespace std;
5 const int maxn = 1e5+5;
6 int w[maxn];
7 int cnt;
8
9 bool cmp(int a, int b){
10 return a > b;
11 }
12
13 int main(){
14 int n;
15 scanf("%d", &n);
16 for(int i = 0; i < n; i++){
17 scanf("%d", &w[i]);
18 }
19
20 sort(w, w+n, cmp); //排序
21
22 cnt = 0;
23 for(int i = 0; i < n; i++){
24 if(cnt <= w[i]){ //能排就排队
25 cnt++;
26 }
27 }
28
29 cout << top << endl;
30 return 0;
31 }
2019 GDUT Rating Contest III : Problem D. Lemonade Line的更多相关文章
- 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 F. Teleportation
题面: Problem F. Teleportation Input file: standard input Output file: standard output Time limit: 15 se ...
- 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 II : Problem G. Snow Boots
题面: G. Snow Boots Input file: standard input Output file: standard output Time limit: 1 second Memory ...
- 2019 GDUT Rating Contest II : Problem C. Rest Stops
题面: C. Rest Stops Input file: standard input Output file: standard output Time limit: 1 second Memory ...
随机推荐
- codeforces 876B
B. Divisiblity of Differences time limit per test 1 second memory limit per test 512 megabytes input ...
- 常用SQL语句1-增删改查
一.名词解释 RDBMS 即关系数据库管理系统(Relational Database Management System)的特点: 1.数据以表格的形式出现 2.每行为各种记录名称 3.每列为记录名 ...
- CVE-2018-8120 提权
经验证,诸多版本的Windows系统均存在该漏洞,文末同时附带一份利用该漏洞制作的提权工具,以供学习.经测试该工具支持Win2003 x32/x64.WinXP x32.Win7 x32/x64, W ...
- 一个汉字在php中占几个字节?
问:一个汉字在php中占几个字节? 答: 对于中文字符,若使用 GBK.Big-5 版本,每个中文字符相当于 2 个字节: 若使用 UTF-8 版本,每个中文字符相当于 3 个字节.
- Apple & iOS & Device Screen Sizes and Orientations & React Native
Apple & iOS & Device Screen Sizes and Orientations & React Native iOS devices https://de ...
- 「NGK每日快讯」2021.1.25日NGK公链第83期官方快讯!
- 负利率时代,NGK DeFi是否会推动资本向加密货币迁徙?
2020年,全球经济危机持续,贸易战争以及天灾人祸使得全球各国的经济雪上加霜,为了挽救低迷的经济,美国.欧洲.日本各国央行竞相放水,全球正在滑入负利率时代. 负利率下,资本加速从法币向数字货币迁徙,因 ...
- RocketMq灰皮书(一)------选型&RocketMQ名词
RocketMq灰皮书(一)------选型&RocketMQ名词 一. MQ选型对比 目前业内常用的MQ框架有一下几种: Kafka RabbitMQ RocketMQ 除此之外,还有Act ...
- C#如何防止程序多次运行的技巧(精典)
一.引言最近发现很多人在论坛中问到如何防止程序被多次运行的问题的,所以这里就记录下来,希望给遇到同样问题的朋友有所参考的,同时也是对自己的一个积累.在介绍具体实现代码之前,我们必须明确解决这个问题的思 ...
- canal数据同步 客户端代码实现
1.引入相关依赖 <dependencies> <dependency> <groupId>org.springframework.boot</groupId ...