Submission #886696

#TimeUsernameProblemLanguageResultExecution timeMemory
886696vjudge1Doktor (COCI17_doktor)C++17
40 / 100
170 ms94232 KiB
#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 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...