# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
74541 | ZZangZZang | Doktor (COCI17_doktor) | C++17 | 110 ms | 24216 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#include <functional>
#include <string>
using namespace std;
typedef long long ll;
const ll INF = 0x3f3f3f3f;
int a[1010101];
int cnt[1010101];
int fm_idx[1010101];
int main()
{
int n;
scanf("%d", &n);
for(int i=0; i<n; i++)
{
scanf("%d", a+i);
}
for(int i=0; i<n; i++)
{
int cur = n - i - 1;
int nidx = -i + a[cur] + n;
cnt[nidx] += 1;
fm_idx[nidx] = max(fm_idx[nidx], cur);
}
int ans = 0;
int maxx = 0;
for(int i=0; i<2*n + 1; i++)
{
if(maxx < cnt[i])
{
maxx = cnt[i];
ans = i;
}
}
if(ans - n > 0)
{
int t1, t2;
t1 = a[ans - n - 1];
t2 = a[n-1];
printf("%d %d\n", t1, t2);
}
else
{
int t1, t2;
t1 = a[0];
t2 = a[fm_idx[ans] + a[fm_idx[ans]] - 1];
printf("%d %d\n", t1, t2);
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |