Submission #173526

# Submission time Handle Problem Language Result Execution time Memory
173526 2020-01-04T13:12:25 Z AllMight Money (IZhO17_money) C++14
0 / 100
2 ms 376 KB
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

const int N = 1000006;

int n;
int a[N];

bool color[N];

int main()
{
	ios_base::sync_with_stdio(false);

	cin >> n;

	for (int i = 0; i < n; i++)
		cin >> a[i];

	int ans = 1;
	bool f = false;
	for (int i = n - 1; i > 0; i--) {
		color[a[i]] = true;

		if (a[i] == a[i - 1] + 1)
			continue;

		if (a[i - 1] > a[i]) {
			ans++;
			f = false;
			continue;
		}

		for (int j = a[i - 1] + 1; j <= a[i]; j++) {
			if (j == a[i]) {
				if (f)
					ans++;
				f = true;
				break;
			}
			if (!color[j]) {
				ans++;
				if (i == 1)
					ans++;
				f = false;
				break;
			}
		}
	}

	cout << ans << endl;

	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -