Educational Codeforces Round 91 (Rated for Div. 2) C. Create The Teams

题目链接:https://codeforces.com/contest/1380/problem/C

题意

给 $n$ 个数分组,要求每组的最小值乘以该组数的个数不小于 $x$ 。

题解

从大到小依次分即可。

代码

#include <bits/stdc++.h>
using ll = long long;
using namespace std;

void solve() {
    int n, x; cin >> n >> x;
    int a[n] = {};
    for (int i = 0; i < n; i++)
        cin >> a[i];
    sort(a, a + n);
    int ans = 0;
    ll num = 1;
    for (int i = n - 1; i >= 0; i--) {
        if (num * a[i] >= x) {
            ++ans;
            num = 1;
        } else ++num;
    }
    cout << ans << "\n";
}

int main() {
    int t; cin >> t;
    while (t--) solve();
}

 

posted @ 2020-07-13 23:36  Kanoon  阅读(281)  评论(0编辑  收藏  举报