# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
116881 | nhimnam120 | Doktor (COCI17_doktor) | C++14 | 1091 ms | 4188 KiB |
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;
long long inp[500005];
signed main()
{
long long n;
cin >> n;
long long ans=0;
for(int i=1;i<=n;i++){
cin >> inp[i];
if(inp[i]==i){
ans++;
}
}
long long mdx=ans;
long long pos1,pos2;
for(int i=1;i<=n-1;i++)
{
for(int j=i+1;j<=n;j++){
long long pre=0;
long long pas=0;
for(int k=i;k<=j;k++){
if(inp[k]==k){
pre++;
}
if(inp[k]==j-(k-i))
{
pas++;
}
}
long long now=ans-pre+pas;
if(now>mdx){
mdx=now;
pos1=i;
pos2=j;
}
}
}
if(mdx==ans){
cout << inp[1]<< " " << inp[1];
return 0;
}
else
{
cout << inp[pos1]<< " " << inp[pos2];
}
}
Compilation message (stderr)
# | 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... |