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> players = a;
  15. sort(players.begin(), players.end());
  16. int pos = lower_bound(players.begin(), players.end(), a[j-1]) - players.begin();
  17. if (pos + k - 1 >= n) {
  18. cout << "NO\n";
  19. continue;
  20. }
  21. bool possible = false;
  22. for (int i = pos; i <= pos + k - 1 && i < n; i++) {
  23. if (players[i] == a[j-1]) {
  24. possible = true;
  25. break;
  26. }
  27. }
  28. cout << (possible ? "YES" : "NO") << "\n";
  29. }
  30. return 0;
  31. }
Success #stdin #stdout 0s 5288KB
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
YES