fork download
  1. #include <bits/stdc++.h>
  2. #include <string>
  3. using namespace std;
  4. #define ll long long
  5. #define dd double
  6. #define ld long double
  7. #define pi 3.14159265359
  8. #define ull unsigned long long
  9. #define yes cout<<"YES\n"
  10. #define no cout<<"NO\n"
  11. #define el "\n"
  12. #define Arwa ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  13. #define fix(x) cout<<fixed<<setprecision(x)
  14. ll gcd(ll a,ll b) {return b==0?a:gcd(b,a%b);}
  15. ll lcm(int a,int b) {return a/gcd(a,b)*b;}
  16. //here we go again
  17. int main()
  18. {
  19. Arwa
  20. int t=1;
  21. cin>>t;
  22. while(t--)
  23. {
  24. int n,q;
  25. cin>>n>>q;
  26. int arr[n],p[n],freq[100001]={};
  27. for(int i=0;i<n;i++)
  28. cin>>arr[i];
  29. int min=1;
  30. for(int i=0;i<n;i++)
  31. {
  32. freq[arr[i]]++;
  33. while(freq[min])
  34. {
  35. min++;
  36. }
  37. p[i]=min;
  38. }
  39. while(q--)
  40. {
  41. int l,r;
  42. cin>>l>>r;
  43. l--;r--;
  44. {
  45. if(l==0)
  46. cout<<p[r]<<el;
  47. }
  48. }
  49. }
  50. return 0;
  51. }
  52.  
Success #stdin #stdout 0.01s 5272KB
stdin
Standard input is empty
stdout
Standard output is empty