fork download
  1. #include <bits/stdc++.h>
  2. // iostream is too mainstream
  3. #include <cstdio>
  4. // bitch please
  5. #include <iostream>
  6. #include <algorithm>
  7. #include <cstdlib>
  8. #include <vector>
  9. #include <set>
  10. #include <map>
  11. #include <queue>
  12. #include <stack>
  13. #include <list>
  14. #include <cmath>
  15. #include <iomanip>
  16. #include <time.h>
  17. #define dibs reserve
  18. #define OVER9000 1234567890123456789LL
  19. #define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
  20. #define tisic 47
  21. #define soclose 1e-8
  22. #define chocolate win
  23. // so much chocolate
  24. #define patkan 9
  25. #define ff first
  26. #define ss second
  27. #define abs(x) ((x < 0)?-(x):x)
  28. #define uint unsigned int
  29. #define dbl long double
  30. #define pi 3.14159265358979323846
  31. using namespace std;
  32. // mylittledoge
  33.  
  34. typedef long long cat;
  35.  
  36. #ifdef DONLINE_JUDGE
  37. // palindromic tree is better than splay tree!
  38. #define lld I64d
  39. #endif
  40.  
  41. int main() {
  42. cin.sync_with_stdio(0);
  43. cin.tie(0);
  44. cout << fixed << setprecision(10);
  45. int T;
  46. cin >> T;
  47. while(T--) {
  48. int N,K;
  49. cin >> N >> K;
  50. vector<int> S(N+1,-1);
  51. for(int i =0; i < N; i++) cin >> S[i];
  52. sort(begin(S),end(S));
  53. auto it =unique(begin(S),end(S));
  54. S.resize(it-begin(S));
  55. for(int i =0; i <= N; i++) {
  56. if(i == N || S[i+1]-S[i]-1 > K) {
  57. cout << S[i]+1+K << "\n";
  58. break;
  59. }
  60. K -=S[i+1]-S[i]-1;
  61. }
  62. }
  63. }
  64.  
  65. // look at my code
  66. // my code is amazing
  67.  
Time limit exceeded #stdin #stdout 5s 1768960KB
stdin
Standard input is empty
stdout
Standard output is empty