#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
vector<int> st={0};
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n;
cin>>n;
int ans=0;
for(int i=1;i<=n;i++)
{
int x;
cin>>x;
while(!st.empty() && st.back()>x)
st.pop_back();
if(st.empty() || st.back()<x)
ans++;
st.push_back(x);
}
cout<<ans<<"\n";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
5 ms |
460 KB |
Output is correct |
5 |
Correct |
7 ms |
460 KB |
Output is correct |
6 |
Correct |
14 ms |
1512 KB |
Output is correct |
7 |
Correct |
14 ms |
1200 KB |
Output is correct |