# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
80909 | 2018-10-23T01:49:15 Z | ngot23 | Doktor (COCI17_doktor) | C++11 | 271 ms | 46716 KB |
#include<bits/stdc++.h> #define rep(i, a, b) for(int i=(a) ; i<=(b) ; ++i) #define Task "" using namespace std; const int N=500001; int a[N*2], n, f[N*2]; vector <int > center[N*2]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); //freopen(Task".inp", "r", stdin); //freopen(Task".out", "w", stdout); cin >> n; rep(i, 1, n) { int u; cin >> u; int ii=2*i-1; if(u==i) f[ii]=1; int xx=2*u-1; int c=(xx+ii)/2; center[c].push_back(abs(c-ii)); a[ii]=u; } rep(i, 1, n*2-1) f[i]+=f[i-1]; int lef, rig, ans=0; rep(i, 2, n*2-1) { if(center[i].size()==0) continue; sort(center[i].begin(), center[i].end()); rep(j, 0, center[i].size()-1) { int r=center[i][j]; int xx=f[i-r-1]+f[n*2-1]-f[i+r]+j+1; if(xx>ans) { ans=xx; lef=a[i-r], rig=a[i+r]; } } } cout << lef << ' ' << rig; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 22 ms | 23804 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 22 ms | 23876 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 22 ms | 24008 KB | Output is correct |
2 | Correct | 22 ms | 24008 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 24 ms | 24076 KB | Output is correct |
2 | Correct | 23 ms | 24076 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 24 ms | 24204 KB | Output is correct |
2 | Correct | 24 ms | 24224 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 25 ms | 24224 KB | Output is correct |
2 | Correct | 24 ms | 24224 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 25 ms | 24428 KB | Output is correct |
2 | Correct | 94 ms | 30052 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 53 ms | 30052 KB | Output is correct |
2 | Correct | 52 ms | 30052 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 271 ms | 43144 KB | Output is correct |
2 | Correct | 156 ms | 43144 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 144 ms | 43144 KB | Output is correct |
2 | Correct | 132 ms | 46716 KB | Output is correct |