人机

取名不要太长,像我这样刚刚好  •  2天前


include <bits/stdc++.h>

using namespace std; stacks;

int main() {

int n;
cin >> n;
int a[105];
for (int i = 1; i <= n; i++)
	cin >> a[i];
int b = 1;
for (int i = 1; i <= n; i++) {
	while (b <= a[i]) {
		s.push(b);
		b++;
	}
	if (a[i] == s.top())
		s.pop();
}
if (s.empty())
	cout << "YES";
else
	cout << "NO";
return 0;

}


评论:

请先登录,才能进行评论