Submission #319908

# Submission time Handle Problem Language Result Execution time Memory
319908 2020-11-06T18:07:04 Z gustason Doktor (COCI17_doktor) C++14
10 / 100
53 ms 2284 KB
#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 time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 404 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 748 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 53 ms 2284 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 28 ms 1516 KB Output isn't correct
2 Halted 0 ms 0 KB -