fork download
  1. #define lld long double
  2. #define PI acos(-1);
  3. #define ys cout << "YES" << endl;
  4. #define no cout << "NO" << endl;
  5. #define logArr(arr) for(auto i:arr) cout<<i<<' ';
  6. #define logArr2D(arr) for (auto i:arr) {for(auto j:i)cout<<j<<' ';cout<<endl;}
  7. #define readArr(arr) for(auto &i : arr) cin>>i;
  8. #define writePrefixArr(arr,s,n) for(int i=s;i<n;i++) {cin>>arr[i]; arr[i]+=arr[i-1];}
  9. #define allArr(arr) arr.begin(), arr.end()
  10. #define ll long long
  11. #define fib(x) ( pow(((1+ sqrt(5))/2 ), x) - pow(((1- sqrt(5))/2 ), x)) / sqrt(5);
  12. //#define ONLINE_JUDGE true;
  13.  
  14. #include<bits/stdc++.h>
  15. using namespace std;
  16.  
  17. void solve() {
  18. int n, l,r;
  19. cin>>n>>l>>r;
  20. vector<int> vct(n+1);
  21. for(int i=1;i<=n;i++)
  22. cin>>vct[i];
  23. int lft=1;
  24. int mxsz = 0, mndiff=INT_MAX;
  25. while(lft<=n){
  26. int rit=lft+1;
  27. int sz=1;
  28. int diff=0;
  29. for(; rit<=n;){
  30. if(vct[rit]<vct[lft]){
  31. sz++;
  32. } else{
  33. // for(int x=lft; x<=rit;x++){
  34. // cout<<vct[x]<<' ';
  35. // }
  36. // cout<<"size: "<<sz<<endl;
  37. break;
  38. }
  39. rit++;
  40. }
  41. diff=abs(l-lft) + abs(r-(rit-1));
  42. if(sz>mxsz){
  43. mxsz=sz;
  44. mndiff=diff;
  45. } else if(sz==mxsz){
  46. mndiff=min(mndiff, diff);
  47. }
  48. lft++;
  49. }
  50. cout<<mxsz<<' '<<mndiff<<endl;
  51. }
  52.  
  53. int main() {
  54. ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  55. #ifndef ONLINE_JUDGE
  56. freopen("input.txt", "r", stdin);
  57. freopen("output.txt", "w", stdout);
  58. #endif
  59. int t = 1;
  60. cin>>t;
  61. while(t--){solve();}
  62. return 0;
  63. }
  64.  
Success #stdin #stdout 0.01s 5304KB
stdin
Standard input is empty
stdout
1 1660717228