# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
670916 | BidoTeima | Doktor (COCI17_doktor) | C++17 | 3 ms | 596 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.
/*
ID: BidoTeima
LANG: C++11
TASK:
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void moo(string filename);
void ACPLS(string str = "")
{
if(str=="NOF")return;
if(str.size())
moo(str);
else{
#ifndef ONLINE_JUDGE
freopen("output.txt", "w", stdout);
freopen("input.txt", "r", stdin);
#endif
}
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
void moo(string fileName){
freopen((fileName+".in").c_str(),"r",stdin);
freopen((fileName+".out").c_str(),"w",stdout);
}
#define tc \
int tttttt/*,subtask*/; \
cin >> tttttt/* >> subtask*/; \
while (tttttt--)/*end
*/
int main()
{
ACPLS();
int n;
cin>>n;
vector<pair<int,int>>v[2 * n + 1];
int pos[n+1],a[n + 1];
int ps[n + 1]={0};
for(int i = 1; i <= n; i++){
int x;
cin>>x;
a[i] = x;
pos[x] = i;
if(i == x){
ps[i]++;
//ans++;
}
ps[i] += ps[i - 1];
}
for(int i = 1; i <= n; i++){
v[i + pos[i]].push_back({min(i, pos[i]), max(i, pos[i])});
//cout<<ps[i]<<'\n';
}
int res = 0;
pair<int,int>ans={1,1};
for(int i = 1; i <= 2 * n; i++){
sort(v[i].begin(), v[i].end());
for(int j = 0; j < (int)v[i].size(); j++){
// contribution = no of (x,y) inside - no opf fixed points inside
if((int)v[i].size() - j - (ps[v[i][j].second] - ps[v[i][j].first - 1]) > res){
res = (int)v[i].size() - j - (ps[v[i][j].second] - ps[v[i][j].first - 1]);
ans={v[i][j].first,v[i][j].second};
}
//cout<<res<<' '<<v[i][j].first<<' '<<v[i][j].second<<'\n';
}
}
cout<<a[ans.first]<<' '<<a[ans.second]<<'\n';
}
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... |