Advertisement
Guest User

Untitled

a guest
Oct 15th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. #include <iostream>
  5. #include <iomanip>
  6. #include <sstream>
  7. #include <stdint.h>
  8. #include <string.h>
  9.  
  10. #include <unordered_set>
  11.  
  12. //#define _USE_MATH_DEFINES
  13. //#include <math.h>
  14.  
  15.  
  16. #include <vector>
  17. #include <list>
  18.  
  19. #include <set>
  20. #include <map>
  21.  
  22. #include <unordered_map>
  23.  
  24. #include <queue>
  25.  
  26. #include <string>
  27.  
  28. #include <vector>
  29.  
  30. #define sqr(x) (x) * (x)
  31.  
  32. #include <algorithm>
  33. #include <functional>
  34.  
  35. #include <bitset>
  36.  
  37. #include <functional>
  38.  
  39. #include <chrono>
  40.  
  41. typedef unsigned int u32;
  42. typedef int i32;
  43.  
  44. typedef unsigned long long int u64;
  45. typedef long long int i64;
  46.  
  47. typedef uint16_t u16;
  48. typedef int16_t i16;
  49.  
  50. typedef uint8_t u8;
  51. typedef int8_t i8;
  52.  
  53.  
  54. using namespace std;
  55. using namespace std::chrono;
  56.  
  57. struct less_key
  58. {
  59. bool operator() (pair<i64, i64> p1, pair<i64, i64> p2)
  60. {
  61. return (p1.first < p2.first || (p1.first == p2.first && p1.second < p2.second));
  62. }
  63. };
  64.  
  65. struct pair_hash
  66. {
  67. std::size_t operator()(const pair<i64, i64>& k) const
  68. {
  69. return static_cast<size_t>(k.first ^ k.second);
  70. }
  71. };
  72.  
  73.  
  74. #include <random>
  75.  
  76. const i64 mod = 1000000007ll;
  77. const i64 inf = 10000000000000007ll;
  78.  
  79. const i64 mod2 = 998244353ll;
  80.  
  81. const double eps = 0.00000001;
  82.  
  83. i64 t;
  84.  
  85. i64 a[100005];
  86.  
  87. void solve() {
  88. i64 n, k;
  89. cin >> n >> k;
  90.  
  91. for (i64 i = 0; i < n; i++) {
  92. cin >> a[i];
  93. }
  94.  
  95. sort(a, a + n);
  96. reverse(a, a + n);
  97.  
  98. i64 R = k;
  99.  
  100. for (i64 i = k; i < n; i++) {
  101. if (a[k - 1] == a[i]) {
  102. R++;
  103. }
  104. }
  105. cout << R << endl;
  106. }
  107.  
  108. int main() {
  109. cin >> t;
  110.  
  111. for (i64 tt = 0; tt < t; tt++) {
  112. solve();
  113. }
  114.  
  115. return 0;
  116. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement