-
Notifications
You must be signed in to change notification settings - Fork 0
/
uva00514.cpp
52 lines (39 loc) · 940 Bytes
/
uva00514.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//
// uva00514.cpp
//
//
// Created by 赵洋 on 15/10/6.
//
//
#include <iostream>
#include <stack>
#include <vector>
using namespace std;
int main(){
int n;
while(cin >> n, n){
int first;
while(cin >> first, first){
vector<int> vi(n, first);
for(int i = 1; i < n; ++i){
int coach;
cin >> vi[i];
}
int count = 1;
stack<int> station;
bool flag = true;
for(int i = 0; i < n; ++i){
while(count <= vi[i]){
station.push(count++);
}
if(vi[i] != station.top()){
flag = false;
break;
}
station.pop();
}
cout << (flag ? "Yes" : "No") << endl;
}
cout << endl;
}
}