Submission #250534

# Submission time Handle Problem Language Result Execution time Memory
250534 2020-07-18T09:12:54 Z Vladikus004 Doktor (COCI17_doktor) C++14
50 / 100
748 ms 53244 KB
#include <bits/stdc++.h>
#define inf 2e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;

const int N = 500000 + 3;
int n, a[N], b[N], sum[N];
map <int, int> cnt, last;
pii mx = {-inf, -inf};

int get_sum(int l, int r){
    if (!l) return sum[r];
    return sum[r] - sum[l - 1];
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
    #endif // LOCAL
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++){
        b[i] = a[i] + i;
        cnt[b[i]]++;
        last[b[i]] = i;
        if (a[i] == i + 1) sum[i] = 1;
        if (i) sum[i] += sum[i - 1];
    }
    for (auto u: cnt){
        mx = max(mx,make_pair(u.second - get_sum(a[last[u.first]] - 1, last[u.first]), u.first));
    }
//    cout << mx.first << " " << last[mx.second] << "\n";
//    for (auto u: cnt) cout << u.first << " : " << u.second << "\n";
//    cout << mx.first << " " << mx.second << "!!!\n";
//    int l = n, r = -1;
//    for (int i = 0; i < n; i++){
//        if (b[i] == mx.second){
//            l = a[i] - 1;
//            r = i;
//        }
//    }
//    cout << a[l]<< " " << a[r];
    cout << a[a[last[mx.second]] - 1] << " " << a[last[mx.second]] << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Incorrect 1 ms 384 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Failed 1 ms 512 KB Checker failed - contact admins or jury
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 768 KB Output is correct
2 Correct 2 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 1152 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Failed 76 ms 7672 KB Checker failed - contact admins or jury
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 748 ms 39972 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 371 ms 23696 KB Output is correct
2 Correct 424 ms 53244 KB Output is correct