fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. int t;
  6. cin >> t;
  7. while (t--) {
  8. int n, j, k;
  9. cin >> n >> j >> k;
  10. vector<int> a(n);
  11. for (int i = 0; i < n; i++) {
  12. cin >> a[i];
  13. }
  14. vector<int> sorted_a = a;
  15. sort(sorted_a.begin(), sorted_a.end());
  16. int threshold = sorted_a[n - k - 1]; // (n-k)-th smallest strength (0-based)
  17. bool possible = (a[j-1] >= threshold);
  18. cout << (possible ? "YES" : "NO") << "\n";
  19. }
  20. return 0;
  21. }
Success #stdin #stdout 0.01s 5320KB
stdin
3
5 2 3
3 2 4 4 1
5 4 1
5 3 4 5 2
6 1 1
1 2 3 4 5 6
stdout
YES
YES
NO