Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main() {
- int T, N, K, index = 0;
- cin >> T;
- for(int k=1; k<=T; k++) {
- cin >> N >> K;
- int arr[N];
- if (T > 50) {
- return false;
- } else if (K > N) {
- return false;
- } else {
- for (int i = 0; i < N; i++) {
- cin >> arr[i];
- }
- }
- for (int i = 0; i < N; i++) {
- for (int j = i; j < N; j++) {
- if (arr[i] > arr[j]) {
- int temp = arr[i];
- arr[i] = arr[j];
- arr[j] = temp;
- }
- }
- }
- for (int i = 0; i < N; i++) {
- if (arr[i] == K) {
- index = i;
- }
- }
- cout << index << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement