# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
886697 |
2023-12-12T16:53:30 Z |
vjudge1 |
Doktor (COCI17_doktor) |
C++17 |
|
191 ms |
49744 KB |
#include <bits/stdc++.h>
using namespace std;
#define sp << " " <<
#define int long long
#define vi vector<int>
#define F(xxx,yyy) for (int xxx=1;xxx<=yyy;xxx++)
#define pii pair<int,int>
#define pb push_back
const int N = 5e5+1;
const int inf = 1e9+1;
vi bit(N,0);
int n;
void add(int p,int v) {
for (int i=p;i<=n;i+=i&-i) bit[i]+=v;
}
int get(int p) {
int ans = 0;
for (int i=p;i>0;i-=i&-i) ans+=bit[i];
return ans;
}
void solve() {
cin >> n;
vi a(n+1);
F(i,n) cin >> a[i];
vi v(n+1);
F(i,n) v[i] = a[i]+i;
pii anss;
int best = 0;
vi poss[2*n+1];
F(i,n) poss[v[i]].push_back(i);
for (int i=1;i<=n;i++){
for (auto it : poss[i+1]) add(it,1);
if (get(i) > best) {
best = get(i);
anss = {1,i};
}
for (auto it : poss[i+1]) add(it,-1);
}
for (int i=1;i<=n;i++) {
//[i,n]
for (auto it : poss[n+i]) add(it,1);
if (get(n)-get(i-1) > best) {
best = get(n)-get(i-1);
anss = {i,n};
}
for (auto it : poss[n+i]) add(it,-1);
}
cout << a[anss.first] sp a[anss.second] << endl;
}
signed main() {
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#ifdef Local
freopen("in","r",stdin);
freopen("out","w",stdout);
#endif
int t = 1;
//cin >> t;
F(i,t) solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4188 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4184 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
4188 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4444 KB |
Output is correct |
2 |
Correct |
2 ms |
4452 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4700 KB |
Output is correct |
2 |
Correct |
2 ms |
4440 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4700 KB |
Output is correct |
2 |
Incorrect |
1 ms |
4188 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
5208 KB |
Output is correct |
2 |
Correct |
47 ms |
28360 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
22 ms |
12120 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
191 ms |
46716 KB |
Output is correct |
2 |
Correct |
79 ms |
41416 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
111 ms |
29160 KB |
Output is correct |
2 |
Correct |
102 ms |
49744 KB |
Output is correct |