# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
887419 |
2023-12-14T13:42:25 Z |
8pete8 |
Doktor (COCI17_doktor) |
C++17 |
|
113 ms |
57784 KB |
#include<iostream>
#include<stack>
#include<map>
#include<vector>
#include<string>
#include<unordered_map>
#include <queue>
#include<cstring>
#include<limits.h>
#include <cassert>
#include<cmath>
#include<set>
#include<algorithm>
#include <iomanip>
#include<numeric> //gcd(a,b)
#include<bitset>
using namespace std;
#define ll long long
#define f first
#define endl "\n"
#define s second
#define pii pair<int,int>
#define ppii pair<int,pii>
#define vi vector<int>
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define F(n) for(int i=0;i<n;i++)
#define lb lower_bound
#define ub upper_bound
#define fastio ios::sync_with_stdio(false);cin.tie(NULL);
#pragma GCC optimize ("03,unroll-loops")
using namespace std;
#define int long long
#define double long double
const int mod=1e9+7,mxn=1e6+5,lg=20,inf=1e18,minf=-1e18;
int val[mxn+10],ans[mxn+10],pref[mxn+10];
vector<int>add[mxn+10];
int32_t main(){
fastio
int n;cin>>n;
for(int i=1;i<=n;i++){
cin>>val[i];
add[max(val[i],i)].pb(min(val[i],i));
if(val[i]==i)pref[i]++;
pref[i]+=pref[i-1];
}
int mx=0,l=1,r=1;
for(int i=1;i<=n;i++){
for(auto j:add[i]){
ans[j+i]++;
if(mx<pref[j-1]+ans[j+i]+pref[n]-pref[i]){
mx=pref[j-1]+ans[j+i]+pref[n]-pref[i];
l=val[j];
r=val[i];
}
}
}
cout<<l<<" "<<r;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
27224 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
27224 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
27224 KB |
Output is correct |
2 |
Correct |
6 ms |
27336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
27228 KB |
Output is correct |
2 |
Correct |
6 ms |
27228 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
29528 KB |
Output is correct |
2 |
Correct |
6 ms |
27228 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
29272 KB |
Output is correct |
2 |
Correct |
6 ms |
27224 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
29784 KB |
Output is correct |
2 |
Correct |
37 ms |
39004 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
33116 KB |
Output is correct |
2 |
Correct |
16 ms |
31356 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
113 ms |
52820 KB |
Output is correct |
2 |
Correct |
58 ms |
44916 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
55 ms |
42580 KB |
Output is correct |
2 |
Correct |
60 ms |
57784 KB |
Output is correct |