fork download
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. int main() {
  6. int t;
  7. cin >> t;
  8.  
  9. while (t--) {
  10. int n, j, k;
  11. cin >> n >> j >> k;
  12.  
  13. vector<int> a(n);
  14. for (int i = 0; i < n; i++) {
  15. cin >> a[i];
  16. }
  17.  
  18. // Player j has 0-indexed position j-1
  19. int player_j_strength = a[j-1];
  20.  
  21. // Count players with strength strictly greater than player j
  22. int stronger_players = 0;
  23. for (int i = 0; i < n; i++) {
  24. if (a[i] > player_j_strength) {
  25. stronger_players++;
  26. }
  27. }
  28.  
  29. // Player j can be in top k if there are at most k-1 players stronger than j
  30. if (stronger_players <= k - 1) {
  31. cout << "YES\n";
  32. } else {
  33. cout << "NO\n";
  34. }
  35. }
  36.  
  37. return 0;
  38. }
Success #stdin #stdout 0.01s 5276KB
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
NO
YES
NO