Submission #319908

#TimeUsernameProblemLanguageResultExecution timeMemory
319908gustasonDoktor (COCI17_doktor)C++14
10 / 100
53 ms2284 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<int> a(n); for(int i = 0; i < n; i++) { cin >> a[i]; } int best = 1, from = 1, to = 1; for(int i = n-1; i > 0;) { int start = a[i], l = 1; while(i > 0 && a[i-1] == a[i]+1 && i != start-1) { l++; i--; } if (l == 1) { i--; continue; } if (l > best) { best = l; if (start >= i) { from = a[i]; to = a[a[i]-1]; } else { from = a[start-1]; to = start; } } } cout << from << " " << to << "\n"; return 0; } //~ check for overflows
#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...