# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
886696 |
2023-12-12T16:47:27 Z |
vjudge1 |
Doktor (COCI17_doktor) |
C++17 |
|
170 ms |
94232 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=2;i<=2*n;i++){
for (auto it : poss[i]) add(it,1);
if (get(i-1) > best) {
best = get(i-1);
anss = {1,i-1};
}
for (auto it : poss[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 |
4188 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 |
1 ms |
4444 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
4696 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
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 |
5 ms |
5212 KB |
Output is correct |
2 |
Runtime error |
62 ms |
52628 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
21 ms |
12124 KB |
Output is correct |
2 |
Correct |
13 ms |
11740 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
170 ms |
94232 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
106 ms |
58708 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |