当前位置:网站首页>Codeforces Round #643 (Div. 2)——B. Young Explorers
Codeforces Round #643 (Div. 2)——B. Young Explorers
2022-07-08 00:02:00 【非长】
题目链接:https://codeforces.com/problemset/problem/1355/B
题目描述: 输入探险家的经验级别,组队时一个队伍的人数不能少于队伍中任一人的经验级别(人数大于队伍中最高经验级别即可),要求能组成最多的队伍数量。
解题思路:贪心 选择经验级别较低的人优先组成满足条件的队伍。——先按经验级别从低到高排序,当满足条件时就组成一个队。
代码:
#include<iostream>
#include<algorithm>
using namespace std;
int num[200005];
int main()
{
int t;
cin >> t;
while (t--)
{
int n;
cin >> n;
for (int i = 0; i < n; i++)
cin >> num[i];
sort(num, num + n);
int ans = 0, count = 0;
for (int i = 0; i < n; i++)
{
count++;
if (count >= num[i])
{
ans++;
count = 0;
}
}
cout << ans << endl;
}
return 0;
}
边栏推荐
- Redis 主从复制
- The usage of rand function in MATLAB
- Probability distribution
- Gnuradio3.9.4 create OOT module instances
- How to get the first and last days of a given month
- Break algorithm --- map
- Grey correlation analysis link (portal) matlab
- Kafka connect synchronizes Kafka data to MySQL
- 2022 refrigeration and air conditioning equipment operation examination questions and refrigeration and air conditioning equipment operation examination skills
- 小金额炒股,在手机上开户安全吗?
猜你喜欢
Measure the voltage with analog input (taking Arduino as an example, the range is about 1KV)
滑环使用如何固定
Scalar / vector / matrix derivation method
Qt - - Packaging Programs - - Don't install Qt - can run directly
Gnuradio3.9.4 create OOT module instances
break net
The beauty of Mathematics -- the principle of fine Fourier transform
About snake equation (3)
Four digit nixie tube display multi digit timing
The persistence mode of redis - RDB and AOF persistence mechanisms
随机推荐
Gnuradio transmits video and displays it in real time using VLC
5、離散控制與連續控制
2022 low voltage electrician examination content and low voltage electrician simulation examination question bank
About snake equation (1)
npm 内部拆分模块
2022 chemical automation control instrument examination summary and chemical automation control instrument simulation examination questions
The Ministry of housing and urban rural development officially issued the technical standard for urban information model (CIM) basic platform, which will be implemented from June 1
Tapdata 的 2.0 版 ,开源的 Live Data Platform 现已发布
About snake equation (2)
break algorithm---刷题map
2021-03-14 - play with generics
break net
Macro definition and multiple parameters
Usage of xcolor color in latex
Understanding of prior probability, posterior probability and Bayesian formula
云原生应用开发之 gRPC 入门
城市土地利用分布数据/城市功能区划分布数据/城市poi感兴趣点/植被类型分布
regular expression
从Starfish OS持续对SFO的通缩消耗,长远看SFO的价值
从cmath文件看名字是怎样被添加到命名空间std中的