제출 #36379

#제출 시각아이디문제언어결과실행 시간메모리
36379cheater2kMoney (IZhO17_money)C++14
0 / 100
0 ms9988 KiB
#include <bits/stdc++.h>
using namespace std;

const int N = 1000005;

int n, a[N];
int T[N];
int ans;

void upd(int x) { for (; x < N; x += x & -x) T[x]++; }
int get(int x) { int res = 0; for (; x > 0; x -= x & -x) res += T[x]; return res; }

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n;
	for (int i = 1; i <= n; ++i) cin >> a[i];

	ans = 1;
	upd(a[1]);
	for (int i = 2; i <= n; ++i) {
		if (a[i] < a[i-1] || get(a[i] - 1) - get(a[i-1]) != 0) 
			++ans; // can't put a[i] and a[i-1] in a subsegment
		upd(a[i]);
		//cerr << i << ' ' << ans << endl;
	}

	cout << ans << endl;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...