当前位置:网站首页>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;
}
边栏推荐
- 2021 Shanghai safety officer C certificate examination registration and analysis of Shanghai safety officer C certificate search
- 2022 high altitude installation, maintenance and demolition examination materials and high altitude installation, maintenance and demolition operation certificate examination
- About snake equation (5)
- php 获取音频时长等信息
- Gnuradio transmits video and displays it in real time using VLC
- Macro definition and multiple parameters
- 碳刷滑环在发电机中的作用
- Deep learning website
- 从cmath文件看名字是怎样被添加到命名空间std中的
- Anaconda3 tutorial on installing and adding Tsinghua image files
猜你喜欢

2021-04-12 - new features lambda expression and function functional interface programming

qt-使用自带的应用框架建立--hello world--使用min GW 32bit

Redis cluster

About snake equation (5)

2022 safety officer-c certificate examination summary and safety officer-c certificate reexamination examination

QT -- package the program -- don't install qt- you can run it directly

Qt - - Packaging Programs - - Don't install Qt - can run directly

Guojingxin center "APEC education +" Shanghai Jiaotong University Japan Cooperation Center x Fudan philosophy class "Zhe Yi" 2022 New Year greetings

2022 refrigeration and air conditioning equipment operation examination questions and refrigeration and air conditioning equipment operation examination skills

2022 operation certificate examination for main principals of hazardous chemical business units and main principals of hazardous chemical business units
随机推荐
Understanding of expectation, variance, covariance and correlation coefficient
Write a pure handwritten QT Hello World
ROS problems (topic types do not match, topic datatype/md5sum not match, MSG XXX have changed. rerun cmake)
腾讯游戏客户端开发面试 (Unity + Cocos) 双重轰炸 社招6轮面试
生态 | 湖仓一体的优选:GBase 8a MPP + XEOS
2022 low voltage electrician examination content and low voltage electrician simulation examination question bank
Problems of font legend and time scale display of MATLAB drawing coordinate axis
Redis cluster
小金额炒股,在手机上开户安全吗?
Anaconda3 download address Tsinghua University open source software mirror station
2022 operation certificate examination for main principals of hazardous chemical business units and main principals of hazardous chemical business units
regular expression
[loss function] entropy / relative entropy / cross entropy
About how USRP sets the sampling frequency below the minimum sampling frequency reached by the hardware
QT build with built-in application framework -- Hello World -- use min GW 32bit
MATLAB R2021b 安装libsvm
Redis 主从复制
ArrayList源码深度剖析,从最基本的扩容原理,到魔幻的迭代器和fast-fail机制,你想要的这都有!!!
Is it safe to open an account on your mobile phone for small amount of stock speculation?
NPDP在国内有认可度吗?看一看就明白了!