-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1812B.cpp
More file actions
43 lines (40 loc) · 925 Bytes
/
1812B.cpp
File metadata and controls
43 lines (40 loc) · 925 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin >> t;
while (t--)
{
int n;
cin >> n;
vector<int> arr(n);
for (int i = 0; i < n; i++)
cin >> arr[i];
vector<int> sort_arr(n);
for (int i = 0; i < n; i++)
cin >> sort_arr[i];
int l=0,r=0;
int head=0,tail=0;
bool change=false;
for(int i=1;i<n;i++) {
if(sort_arr[i]>=sort_arr[i-1]) {
tail++;
if(arr[i]!=sort_arr[i]) change=true;
}
else {
change=false;
head=i;
tail=i;
}
if(((tail-head)>(r-l))&&change) {
if (change) {
l=head;
r=tail;
}
}
}
cout<<l+1<<" "<<r+1<<'\n';
}
return 0;
}