#include <bits/stdc++.h>
using namespace std;
typedef int ll;
#define endl '\n'
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
ll n;cin>>n;
vector<ll>arr(n);
for(auto &i:arr)cin>>i;
ll x=1,y=1;
ll mx=0;
for(ll i=0;i<n;i++){
for(ll j=i+1;j<n;j++){
reverse(arr.begin()+i,arr.begin()+j+1);
ll cnt=0;
for(ll k=0;k<n;k++){
cnt+=(arr[k]==k+1);
}
reverse(arr.begin()+i,arr.begin()+j+1);
if(cnt>mx){
x=arr[i];y=arr[j];
mx=cnt;
}
}
}
cout<<x<<" "<<y<<endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
31 ms |
288 KB |
Output is correct |
2 |
Correct |
65 ms |
288 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1049 ms |
204 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1075 ms |
204 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1062 ms |
204 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1071 ms |
332 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1070 ms |
588 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1071 ms |
2124 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1073 ms |
1356 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |