Submission #421889

# Submission time Handle Problem Language Result Execution time Memory
421889 2021-06-09T13:18:09 Z Drew_ Sequence (BOI14_sequence) C++17
25 / 100
10 ms 888 KB
#include <iostream>
using namespace std;

const int MAX = 1e5 + 69;

int n;
int ar[MAX];
int val0[6] = {1, 10, 100, 1000, 10000, 100000};
int val1[6] = {1, 11, 111, 1111, 11111, 111111};

inline bool yes(int num)
{
	for (int i = 0; i < n; ++i)
	{
		bool ok = false;
		int tmp = num + i;

		while (tmp)
		{
			if (tmp % 10 == ar[i]) { ok = true; break; }
			tmp /= 10;
		}

		if (!ok)
			return false;
	}
	return true;
}

inline int brute()
{
	for (int i = 1;; ++i)
	{
		if (yes(i))
			return i;
	}
	return -1;
}

inline int greedy()
{
	if (ar[0] == 0)
	{
		int id = -1;
		for (int i = 0; i < 6; ++i)
		{
			if (val1[i] >= n)
			{
				id = i;
				break;
			}
		}

		int res = 10;
		for (int i = 0; i < id; ++i)
			res *= 10;
		return res;
	}
	else if (ar[0] <= 8)
	{

		int id = -1;
		for (int i = 0; i < 6; ++i)
		{
			if (val0[i] >= n)
			{
				id = i;
				break;
			}
		}

		int res = ar[0];
		for (int i = 0; i < id; ++i)
			res *= 10;
		return res;
	}
	else
	{

		int id = -1;
		for (int i = 0; i < 6; ++i)
		{
			if (val1[i] >= n)
			{
				id = i;
				break;
			}
		}

		int res = 0;
		for (int i = 0; i < id; ++i)
			res = res * 10 + 8;
		return res * 10 + 9;
	}
}

int main()
{
	ios :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> ar[i];
	cout << greedy() << '\n';;


	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 388 KB Output is correct
4 Correct 2 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 6 ms 716 KB Output is correct
8 Correct 4 ms 588 KB Output is correct
9 Correct 10 ms 844 KB Output is correct
10 Correct 9 ms 888 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -