# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
82319 | 2018-10-29T22:13:00 Z | thiago4532 | Doktor (COCI17_doktor) | C++17 | 360 ms | 79132 KB |
#include <bits/stdc++.h> using namespace std; const int maxn = 2*500010; int v[maxn], pref[maxn], n; typedef pair<int, int> pii; vector<int> c[maxn]; vector<pii> p; vector<int> ord[maxn]; inline int qq(int a, int b){ return pref[b] - pref[a-1]; } void ordena(){ for(auto v : p) ord[v.first].push_back(v.second); p.clear(); for(int i=0;i<maxn;i++){ if(ord[i].empty()) continue; for(auto v : ord[i]) p.push_back({i, v}); } } int main(){ ios::sync_with_stdio(false), cin.tie(0); cin >> n; for(int i=1;i<=n;i++){ cin >> v[i<<1]; v[i<<1] *= 2; int centro = (v[(i<<1)] + (i<<1))/2; p.push_back({abs(centro - (i<<1)), centro}); } ordena(); for(int i=1;i<=n;i++) c[p[i].second].push_back(p[i].first); for(int i=1;i<=n;i++) if(v[i<<1] == (i<<1)) pref[i<<1] = 1; for(int i=1;i<=2*n;i++) pref[i] += pref[i-1]; int ans=0, a, b; for(int i=1;i<=2*n;i++){ //sort(c[i].begin(), c[i].end()); for(int j=0;j<c[i].size();j++){ int qtd = j + 1 - qq(i-c[i][j], i+c[i][j]) + (!(i&1) && v[i] == i); if(qtd > ans){ ans = qtd; a = i-c[i][j]; b = i+c[i][j]; } } } cout << v[a]/2 << " " << v[b]/2 << "\n"; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 50 ms | 47352 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 46 ms | 47424 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 47 ms | 47476 KB | Output is correct |
2 | Correct | 48 ms | 47488 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 48 ms | 47672 KB | Output is correct |
2 | Correct | 48 ms | 47820 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 52 ms | 47840 KB | Output is correct |
2 | Correct | 48 ms | 47840 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 49 ms | 47916 KB | Output is correct |
2 | Correct | 46 ms | 47916 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 51 ms | 48224 KB | Output is correct |
2 | Correct | 116 ms | 62536 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 87 ms | 62536 KB | Output is correct |
2 | Correct | 69 ms | 62536 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 360 ms | 79132 KB | Output is correct |
2 | Correct | 205 ms | 79132 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 211 ms | 79132 KB | Output is correct |
2 | Correct | 159 ms | 79132 KB | Output is correct |