제출 #644052

#제출 시각아이디문제언어결과실행 시간메모리
644052ymmMoney (IZhO17_money)C++17
100 / 100
1071 ms54232 KiB
#include <bits/stdc++.h>
#define Loop(x,l,r) for (ll x = (l); x < (r); ++x)
#define LoopR(x,l,r) for (ll x = (r)-1; x >= (l); --x)
typedef long long ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll , ll > pll;
using namespace std;

int main()
{
	cin.tie(0) -> sync_with_stdio(false);
	int n;
	cin >> n;
	set<int> s;
	auto it = s.end();
	int ans = 1;
	int lst = -1;
	Loop (i,0,n) {
		int x;
		cin >> x;
		auto it2 = s.lower_bound(x);
		auto it3 = s.upper_bound(x);
		if (x < lst || (it != it2 && it != it3)) {
			it = it3;
			++ans;
		}
		s.insert(x);
		lst = x;
	}
	cout << ans << '\n';
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...