Submission #473554

#TimeUsernameProblemLanguageResultExecution timeMemory
473554Beboo44Doktor (COCI17_doktor)C++14
0 / 100
179 ms4044 KiB
#include <bits/stdc++.h> using namespace std; #define all(v) ((v).begin()), ((v).end()) #define sz(v) ((int)((v).size())) typedef long long ll; typedef vector<int> vi; typedef vector<pair<ll , int> > vpli; typedef set<char> st; typedef stack<int> s; typedef deque<int> dq; typedef queue<int> q; #define fast_io ios_base::sync_with_stdio(0); cin.tie(0) int main() { ll n; cin>>n; vector<ll>v(n); for(int i=0; i<n; ++i){ cin>>v[i]; } ll sum = 1; ll maxi=0; ll indx=0; ll start=0; for(int i=1; i<n; ++i){ if(v[i]==v[i-1]-1){ ++sum; } else{ if(sum>maxi){ maxi=sum; sum=1; indx=start; } start = i; } } if(sum>maxi){ indx = start; maxi=sum; } if(indx<=n/2){ cout<<v[indx]<<" "<<v[v[indx]-1]; } else{ cout<<v[indx+maxi-1]<<" "<<v[indx+maxi-2]; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...