# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
82205 |
2018-10-29T13:26:03 Z |
luciocf |
Doktor (COCI17_doktor) |
C++14 |
|
17 ms |
908 KB |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 6e3+10;
int num[maxn], n;
void get_30(void)
{
int ans = 0, ind1 = num[1], ind2 = num[2];
for (int l = 1; l <= n; l++)
{
for (int r = l; r <= n; r++)
{
int aux = 0;
for (int i = l; i <= r; i++)
{
int x = i-l;
if (num[i] == r-x) aux++;
}
if (aux > ans)
{
ans = aux;
ind1 = num[l], ind2 = num[r];
}
}
}
cout << ind1 << " " << ind2 << "\n";
}
void get_60(void)
{
int ans = 0, ind1 = num[1], ind2 = num[2];
for (int i = 1; i <= n; i++)
{
if (num[i] < i) continue;
int aux = 0;
for (int j = i; j <= num[i]; j++)
if (num[j]+j == num[i]+i) aux++;
if (aux >= ans)
{
ans = aux;
ind1 = num[i], ind2 = num[num[i]];
}
}
for (int i = 1; i <= n; i++)
{
if (num[i] > i) continue;
int aux = 0;
for (int j = num[i]; j <= i; j++)
if (num[j]+j == num[i]+i) aux++;
if (aux >= ans)
{
ans = aux;
ind1 = num[num[i]], ind2 = num[i];
}
}
cout << ind1 << " " << ind2 << "\n";
}
int main(void)
{
ios::sync_with_stdio(false); cin.tie(0);
cin >> n;
for (int i = 1; i <= n; i++)
cin >> num[i];
if (n <= 500) get_30();
else get_60();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
500 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
500 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
500 KB |
Output is correct |
2 |
Correct |
4 ms |
672 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
672 KB |
Output is correct |
2 |
Correct |
5 ms |
672 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
672 KB |
Output is correct |
2 |
Correct |
3 ms |
672 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
4 ms |
816 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 |
4 ms |
860 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 |
3 ms |
860 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 |
3 ms |
908 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |