Files
contests/Codeforces/CodeforcesRound1037(Div3)/CIWillDefinitelyMakeIt/solution.cpp

38 lines
486 B
C++

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
void solve() {
int n, k;
cin >> n >> k;
vector<int> a(n);
for (auto &i : a)
cin >> i;
int h = a[k - 1];
sort(a.begin(), a.end());
int time = 0;
for (auto H : a) {
if (H <= h)
continue;
time += H - h;
if (time > h) {
cout << "NO\n";
return;
}
h = H;
}
cout << "YES\n";
}
int main() {
int t;
cin >> t;
while (t--) {
solve();
}
}