Submission #173535

# Submission time Handle Problem Language Result Execution time Memory
173535 2020-01-04T14:12:06 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;
const int INF = 100000009;

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 = 0, mn = INF, mx = -INF;
	for (int i = 0; i < n - 1; i++) {
		int l = a[i];
		while (i < n - 1 && a[i] < a[i + 1])	i++;
		int r = a[i];
		
		if ((l < mx && mx < r) || (l < mn && mn < r))
			ans++;

		mn = min(mn, l), mx = max(mx, r);
		ans++;
	}

	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 -