B. Young Explorers
B.年轻探索者
time limit per test: 2 seconds 每次测试的时间限制:2秒
memory limit per test: 256 megabytes 每次测试的内存限制:256兆字节
input. standard input 投入。标准输入
output: standard output 产出:标准产出
Young wilderness explorers set off to their first expedition led by senior explorer Russell. Explorers went into a forest, set up a camp and Young wilderness explorers set off to their first expedition led by senior explorer Russell. Explorers went into a forest, set up a camp and
decided to split into groups to explore as much interesting locations as possible. Russell was trying to form groups, but ran into some 决定分成几个小组,尽可能多地探索有趣的地点。罗素试图组成小组,但遇到了一些人
ificultits… 有意义的…。
Most of the young explorers are inexperienced, and sending them alone would be a mistake. Even Russell himself became senior explorer Most of the young explorers are inexperienced, and sending them alone would be a mistake. Even Russell himself became senior explorer
not long ago. Each of young explorers has a positive integer parameter Ci一his inexperience. Russell decided that an explorer with 不久前。每个年轻的探险家都有一个正整数参数ci一他的经验不足。罗素决定一个探险家
inexperience e can only join the group of e or more people. 缺乏经验的e只能加入e或更多的人。
Now Russell needs to figure out how many groups he can organize. It’s not necessary to include every explorer in one of the groups: some 现在罗素需要弄清楚他能组织多少个团体。没有必要将每个探险家都包括在其中一个组中:
can stay in the camp. Russell is worried about this expedition, so he asked you to help him. can stay in the camp. Russell is worried about this expedition, so he asked you to help him.
Input 输入
The first line contains the number of independent test cases T(1≤T < 2.10*). Next 2T lines contain description of test cases. 第一行包含独立测试用例T的数量(1≤T<2.10*)。接下来的2T行包含测试用例的描述。
The first line of description of each test case contains the number of young explorersN(1 < N < 2.105). 每个测试用例的第一行描述包含年轻探索者N的数量(1<N<2.105)。
The second line contains N integers e1, e…eN (1≤ei≤N), where eq is the inexperience of the i-th explorer. The second line contains N integers e1, e…eN (1≤ei≤N), where eq is the inexperience of the i-th explorer.
Its guaranteed that sum of all N doesn’t exceed 3.105. 它保证所有N的总和不超过3.105。
Output 输出量
Print T numbers, each number on a separate line. 打印T号,每个数字在一个单独的行。
In i-th line print the maximum number of groups Russell can form in i-th test case. 在第一行打印中,罗素在第一次测试用例中可以形成的最大组数.
排序是数值大的先满足即可
int t,n,a[300010];
int main(){
cin>>t;
while(t--){
cin>>n;
for(int i=1;i<=n;i++)
cin>>a[i];
sort(a+1,a+1+n);
int ans=0,cnt=0;
for(int i=1;i<=n;i++){
cnt++;
if(cnt>=a[i]){
cnt=0;
ans++;
}
}
cout<<ans<<endl;
}
}
|