Submission #74541

# Submission time Handle Problem Language Result Execution time Memory
74541 2018-09-03T11:48:59 Z ZZangZZang Doktor (COCI17_doktor) C++17
70 / 100
110 ms 24216 KB
#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

doktor.cpp: In function 'int main()':
doktor.cpp:18:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
doktor.cpp:21:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", a+i);
   ~~~~~^~~~~~~~~~~
# 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 480 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 480 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 480 KB Output is correct
2 Correct 16 ms 480 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 660 KB Output is correct
2 Correct 2 ms 660 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 748 KB Output is correct
2 Incorrect 2 ms 748 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 788 KB Output is correct
2 Correct 44 ms 3808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 4856 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 110 ms 15964 KB Output is correct
2 Correct 67 ms 15964 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 51 ms 17180 KB Output is correct
2 Correct 72 ms 24216 KB Output is correct