# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
82222 | 2018-10-29T14:23:31 Z | thiago4532 | Doktor (COCI17_doktor) | C++17 | 15 ms | 8268 KB |
#include <bits/stdc++.h> using namespace std; const int maxn = 2*50010; int v[maxn], pref[maxn], n; vector<int> c[maxn]; inline int qq(int a, int b){ return pref[b] - pref[a-1]; } 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; c[centro].push_back(abs(centro - (i<<1))); } 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 | 4 ms | 2680 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 2764 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 2880 KB | Output is correct |
2 | Correct | 5 ms | 2880 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 3004 KB | Output is correct |
2 | Correct | 4 ms | 3024 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 3152 KB | Output is correct |
2 | Correct | 4 ms | 3152 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 3152 KB | Output is correct |
2 | Correct | 5 ms | 3152 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 3324 KB | Output is correct |
2 | Runtime error | 7 ms | 5500 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 15 ms | 8268 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 10 ms | 8268 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 9 ms | 8268 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |