Submission #235127

#TimeUsernameProblemLanguageResultExecution timeMemory
235127NONAMEDoktor (COCI17_doktor)C++17
40 / 100
1098 ms4220 KiB
#include <bits/stdc++.h> #define N 5 * 100500 using namespace std; int n, pf[N], a[N], ans, al = 0, ar = 0; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; a[i]--; pf[i] = (i - 1 < 0) ? 0 : pf[i - 1]; pf[i] += (a[i] == i); } for (int i = 0; i < n; i++) for (int j = i; j < n; j++) { int l = i, r = j, cur = 0; while (l < r) { cur += (a[l] == r); cur += (a[r] == l); l++, r--; } if (l == r && a[l] == l) cur++; cur += (i - 1 < 0) ? 0 : pf[i - 1]; cur += (pf[n - 1] - pf[j]); if (cur > ans) { ans = cur; al = i; ar = j; } } cout << a[al] + 1 << ' ' << a[ar] + 1; }
#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...