Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <iostream>
- #include <iomanip>
- #include <sstream>
- #include <stdint.h>
- #include <string.h>
- #include <unordered_set>
- //#define _USE_MATH_DEFINES
- //#include <math.h>
- #include <vector>
- #include <list>
- #include <set>
- #include <map>
- #include <unordered_map>
- #include <queue>
- #include <string>
- #include <vector>
- #define sqr(x) (x) * (x)
- #include <algorithm>
- #include <functional>
- #include <bitset>
- #include <functional>
- #include <chrono>
- typedef unsigned int u32;
- typedef int i32;
- typedef unsigned long long int u64;
- typedef long long int i64;
- typedef uint16_t u16;
- typedef int16_t i16;
- typedef uint8_t u8;
- typedef int8_t i8;
- using namespace std;
- using namespace std::chrono;
- struct less_key
- {
- bool operator() (pair<i64, i64> p1, pair<i64, i64> p2)
- {
- return (p1.first < p2.first || (p1.first == p2.first && p1.second < p2.second));
- }
- };
- struct pair_hash
- {
- std::size_t operator()(const pair<i64, i64>& k) const
- {
- return static_cast<size_t>(k.first ^ k.second);
- }
- };
- #include <random>
- const i64 mod = 1000000007ll;
- const i64 inf = 10000000000000007ll;
- const i64 mod2 = 998244353ll;
- const double eps = 0.00000001;
- i64 t;
- i64 a[100005];
- void solve() {
- i64 n, k;
- cin >> n >> k;
- for (i64 i = 0; i < n; i++) {
- cin >> a[i];
- }
- sort(a, a + n);
- reverse(a, a + n);
- i64 R = k;
- for (i64 i = k; i < n; i++) {
- if (a[k - 1] == a[i]) {
- R++;
- }
- }
- cout << R << endl;
- }
- int main() {
- cin >> t;
- for (i64 tt = 0; tt < t; tt++) {
- solve();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement