Submission #250538

#TimeUsernameProblemLanguageResultExecution timeMemory
250538Vladikus004Doktor (COCI17_doktor)C++14
60 / 100
562 ms28696 KiB
#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 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...