CompetitiveProgramming/src/bin/cf-1889b.cc

29 lines
618 B
C++
Raw Normal View History

2024-01-18 04:40:12 +00:00
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
void solve() {
int n, c; cin >> n >> c;
vector<ll> a(n);
for (int i = 0; i < n; ++i) cin >> a[i];
vector<int> idx(n - 1);
iota(idx.begin(), idx.end(), 1);
sort(idx.begin(), idx.end(), [&](int i, int j) {
if (a[i] == a[j]) return i < j;
return a[i] > a[j];
});
ll sum = a[0];
for (auto&& i : idx) {
sum += a[i];
if (sum < (i + 1) * c) {
cout << "No\n";
return;
}
}
cout << "Yes\n";
}
int main() {
int t; cin >> t;
while (t--) solve();
}