AhmedAshraff

Untitled

Jul 15th, 2024
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <bits/stdc++.h>
  3. #define boAshraf { ios_base::sync_with_stdio(false); cin.tie(NULL); }
  4. #define ll long long
  5. #define sz(s) (int)(s).size()
  6. #define endl "\n"
  7. #define ordered_set tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update>
  8. #include <ext/pb_ds/assoc_container.hpp>
  9. #include <ext/pb_ds/tree_policy.hpp>
  10. using namespace __gnu_pbds;
  11. using namespace std;
  12. void File();
  13. void sol();
  14. int main() {
  15. boAshraf
  16. File();
  17. int t = 1;
  18. cin >> t;
  19. while (t--) {
  20. sol();
  21. }
  22. return 0;
  23. }
  24. void sol() {
  25. int n,l,r;cin>>n>>l>>r;
  26. vector<int>v(n+1),pre(n+1);
  27. v[0]=-2e9;
  28. int mx=0;
  29. for (int i = 1; i <=n ; ++i) {
  30. cin>>v[i];
  31. if(v[i]<=v[i-1])pre[i]=pre[i-1]+1;
  32. else pre[i]=1;
  33. mx=max(mx,pre[i]);
  34. }
  35. int mn=n*2;
  36. for (int i = n; i >=1 ; --i) {
  37. if(pre[i]==mx)mn=min(mn,abs(r-i)+abs(l-(i-mx+1)));
  38. }
  39. cout<<mx<<' '<<mn<<endl;
  40. }
  41.  
  42. void File() {
  43. #ifndef ONLINE_JUDGE
  44. freopen("input.txt", "r", stdin);
  45. freopen("output.txt", "w", stdout);
  46. #endif
  47. }
Advertisement
Add Comment
Please, Sign In to add comment