#include <bits/stdc++.h>
#define int long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
signed main(){
fastio
int n;
cin >> n;
int arr[n];
stack<int> s;
int ans = 0;
for(auto &x : arr){
cin >> x;
while(!s.empty()&&s.top()>x){
s.pop();
}
if(s.empty()||s.top()!=x){
ans++;
s.push(x);
}
}
cout << ans << "\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
3 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
4 |
Incorrect |
4 ms |
748 KB |
Output isn't correct |
5 |
Incorrect |
6 ms |
876 KB |
Output isn't correct |
6 |
Correct |
15 ms |
1516 KB |
Output is correct |
7 |
Incorrect |
12 ms |
1132 KB |
Output isn't correct |