# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
197372 |
2020-01-20T15:38:55 Z |
Neklixx |
Doktor (COCI17_doktor) |
C++14 |
|
247 ms |
45316 KB |
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define sh cin.tie(0); cin.sync_with_stdio(0); cout.tie(0);
#define FILE freopen("test.in", "r", stdin);
#define vprint(v) for (int ii = 0; ii < v.size(); ii++){cout << v[ii] << " ";}
#define debugv(v) if (v.size() != 0) {cout << "[ "; for (int __ = 0; __ < (int)(v.size()) - 1; __++){cout << v[__] << ", ";} cout << v[(int)(v.size()) - 1] << " ]" << endl;} else {cout << "[]" << endl;}
#define debug cout << "-----------------------------------------------" << endl;
#define print1(a) cout << "{ " << a << " }" << endl;
#define print2(a, b) cout << "{ " << a << ", " << b << " }" << endl;
#define print3(a, b, c) cout << "{ " << a << ", " << b << ", " << c << " }" << endl;
#define print4(a, b, c, d) cout << "{ " << a << ", " << b << ", " << c << ", " << d << " }" << endl;
using namespace std;
//#define int long long
const int INF = 1e9 + 228;
const int MAXN = 5e5 + 228;
vector<int> rot[MAXN][2];
int pos[MAXN];
signed main()
{
#ifdef LOCAL
FILE;
#endif
sh;
int n;
cin >> n;
vector<int> v;
for (int i = 0; i < n; i++) {
int aa;
cin >> aa;
v.pb(aa - 1);
}
for (int i = 0; i < n; i++) {
int nw = v[i];
pos[nw] = i;
int len = abs(nw - i) + 1;
int mid = min(nw, i) + len / 2;
mid--;
//print4(i, nw, mid, len);
rot[mid + (len % 2)][len % 2].pb(min(nw, i));
}
vector<int> p;
p.pb(0);
for (int i = 0; i < n; i++) {
p.pb(p[i] + (v[i] == i));
}
int mx = 0, l = 0, r = 0;
for (int mid = 0; mid < n; mid++) {
int now = 0;
int re = 0;
for (auto to : rot[mid][0]) {
now++;
re = now - (p[mid + mid - to + 2] - p[to]);
if (re > mx) {
mx = re;
l = to;
r = mid + mid - to + 1;
//print4(mid, re, l, r);
}
}
//print1(mx);
now = 0;
re = 0;
for (auto to : rot[mid][1]) {
now++;
re = now - (p[mid + mid - to + 1] - p[to]);
if (re > mx) {
mx = re;
l = to;
r = mid + mid - to;
}
}
//print1(mx);
}
cout << v[l] + 1 << ' ' << v[r] + 1 << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
25 ms |
23800 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
25 ms |
23800 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
25 ms |
23800 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
26 ms |
23928 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
24056 KB |
Output is correct |
2 |
Correct |
26 ms |
23928 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
24056 KB |
Output is correct |
2 |
Correct |
25 ms |
23928 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
28 ms |
24312 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
54 ms |
27860 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
247 ms |
45316 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
144 ms |
37792 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |