Precreation contest files
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
#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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user