Submission #82188

# Submission time Handle Problem Language Result Execution time Memory
82188 2018-10-29T13:02:26 Z luciocf Doktor (COCI17_doktor) C++14
50 / 100
16 ms 1332 KB
#include <bits/stdc++.h>

using namespace std;

const int maxn = 5e3+10;

int num[maxn];

int main(void)
{
	int n;
	cin >> n;

	for (int i = 1; i <= n; i++)
		cin >> num[i];

	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 = n; i >= 1; 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";
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 508 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 508 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 516 KB Output is correct
2 Correct 3 ms 528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 612 KB Output is correct
2 Correct 5 ms 636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 776 KB Output is correct
2 Correct 2 ms 776 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 1164 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 5 ms 1180 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 1212 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 5 ms 1332 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -