This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
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++){
ll cnt=0,sz=j-i+1;
for(ll k=i;k<=j;k++){
ll idx=i+(sz-k);
cnt+=(arr[k]==idx);
}
if(cnt>mx){
x=arr[i];y=arr[j];
mx=cnt;
}
}
}
cout<<x<<" "<<y<<endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |