Submission #250538

# Submission time Handle Problem Language Result Execution time Memory
250538 2020-07-18T09:29:09 Z Vladikus004 Doktor (COCI17_doktor) C++14
60 / 100
562 ms 28696 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];
        mx = max(mx, make_pair(cnt[b[i]] - get_sum(a[i] - 1, i), i));
    }

    cout << a[a[mx.second] - 1] << " " << a[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 0 ms 384 KB Output is correct
2 Incorrect 1 ms 384 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 512 KB Output is correct
2 Correct 1 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 4 ms 768 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 48 ms 4472 KB Output is correct
2 Correct 13 ms 2048 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 562 ms 23032 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 229 ms 13712 KB Output is correct
2 Correct 245 ms 28696 KB Output is correct