Submission #82210

# Submission time Handle Problem Language Result Execution time Memory
82210 2018-10-29T13:32:00 Z luciocf Doktor (COCI17_doktor) C++14
60 / 100
21 ms 952 KB
#include <bits/stdc++.h>

using namespace std;

const int maxn = 6e3+10;

int num[maxn], soma[maxn], 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 (num[i] == i) soma[i] = soma[i-1]+1;
		else soma[i] = soma[i-1];
	}

	int ans = 0, ind1 = num[1], ind2 = num[2];

	for (int i = 1; i <= n; i++)
	{
		if (num[i] < i) continue;

		int aux = soma[i-1]+soma[n]-soma[num[i]];
		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 = soma[n]-soma[i]+soma[num[i]-1];
		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 380 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 Correct 2 ms 508 KB Output is correct
2 Correct 2 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 596 KB Output is correct
2 Correct 4 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 596 KB Output is correct
2 Correct 5 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 596 KB Output is correct
2 Correct 2 ms 680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 820 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 888 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 952 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 952 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -