Submission #82191

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

using namespace std;

const int maxn = 6e3+10;

int num[maxn];

int main(void)
{
	ios::sync_with_stdio(false); cin.tie(0);
	
	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 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 424 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 464 KB Output is correct
2 Correct 3 ms 668 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 668 KB Output is correct
2 Correct 4 ms 668 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 668 KB Output is correct
2 Correct 2 ms 668 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 876 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 876 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 876 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 876 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -