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 ...
随机推荐
- 缓冲区溢出实验 2 sizeof/strlen
实验环境.代码.及准备 https://www.cnblogs.com/lqerio/p/12870834.html vul2 下面只给出有漏洞部分的代码.Vul2问题为sizeof函数在计算时会考虑 ...
- IFIX 目录结构
iFIX使用了许多目录存储程序和数据文件.用路径配置对话框来指定iFIX目录的位置和名称.可在SCU工具箱中单击"路径"按钮显示该对话框. 当iFIX安装后它将创建一个目录,该目录 ...
- spring-cloud-netflix-eureka-server
一.构建springcloud父pom工程,管理版本 pom.xml <?xml version="1.0" encoding="UTF-8"?> ...
- hdu4801 PocketCube 2阶魔方
http://acm.hdu.edu.cn/showproblem.php?pid=4801 1. 题目描述给定一个2×2×22×2×2的魔方,当某个面上的4个小块颜色均相同时,称这个面为comple ...
- Shell 编程快速上手
Shell 编程快速上手 test.sh #!/bin/sh cd ~ mkdir shell_tut cd shell_tut for ((i=0; i<10; i++)); do touch ...
- code screenshot beautify plugin & 代码截图美化插件
code screenshot beautify plugin & 代码截图美化插件 代码截图美化 codesnap 微信分享代码截图 https://github.com/kufii/Cod ...
- JavaScript & Automatic Semicolon Insertion
JavaScript & Automatic Semicolon Insertion ECMA 262 真香警告️ https://www.ecma-international.org/ecm ...
- tree traversal
tree traversal tree 遍历 中序,顺序,左中右 先序,先父节点,中左右 后序,先子节点,左右中 二叉搜索树 "use strict"; /** * * @auth ...
- vue SSR & asyncData & nuxt.js
vue SSR & asyncData & nuxt.js https://zh.nuxtjs.org/api/ https://www.cnblogs.com/xgqfrms/p/1 ...
- vue技术栈
1 vue 说明:vue生命周期:技术点:1:常用的API:computed,methods,props,mounted,created,components 2vue-cli说明:vue绞手架,用于 ...