Submission #710071

#TimeUsernameProblemLanguageResultExecution timeMemory
710071arcaneMoney (IZhO17_money)C++17
0 / 100
1 ms212 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
int32_t main(){
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int ans = 0, n, x, prev = -1; cin >> n;
	set <int> ms;
	for (int i = 0; i < n; i++){
		cin >> x;
		ms.insert(x);
		//cerr << prev << ' ' << x << '\n';
		if (prev == x) continue;
		auto it = ms.upper_bound(x - 1);
		if (it == ms.begin() or *(--it) != prev) ans += 1;
		prev = x;
	}
	cout << ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...