七月十三日训练总结

There are n programmers that you want to split into several non-empty teams. The skill of the i-th programmer is ai. You want to assemble the maximum number of teams from them. There is a restriction for each team: the number of programmers in the team multiplied by the minimum skill among all programmers in the team must be at least x.

Each programmer should belong to at most one team. Some programmers may be left without a team.

Calculate the maximum number of teams that you can assemble.

Input
The first line contains the integer t (1≤t≤1000) — the number of test cases.

The first line of each test case contains two integers n and x (1≤n≤105;1≤x≤109) — the number of programmers and the restriction of team skill respectively.

The second line of each test case contains n integers a1,a2,…,an (1≤ai≤109), where ai is the skill of the i-th programmer.

The sum of n over all inputs does not exceed 105.

Output
For each test case print one integer — the maximum number of teams that you can assemble.

Example
Input
3
5 10
7 11 2 9 5
4 8
2 4 2 3
4 11
1 3 3 7
Output
2
1
0
补一下c题 ,这是今天一开始自己做并没有思路的题目,是看过题解才弄明白的,题目大意就是有N个人要分组,每个人若有组则只参加一组,每个人有技能值 ,组队要求为:组员人数与组员中最低技能值的乘积要不小于x。问最多可以分几组。
做的话就是一个贪心的题目,要分最多组肯定是每组的人数越少越好。当人数越少时,为了满足限制,则需要组内最低技能值高,因此从大到小遍历所有人,判断当前人数和最低技能值的乘积是否够组成一个组就可以了

#include <iostream>
#include <algorithm>
using namespace std;
int a[100005];
int main()
{
    int t;
    cin>>t;
    while(t--){
        int n,x; cin>>n>>x;
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        sort(a,a+n);
        int ans=0;int cnt = 0;
        int k = n;
        while(k--){
            cnt++;
            if(cnt*a[k]>=x){
                ans++;
                cnt = 0;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值