# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
782687 | 1075508020060209tc | Po (COCI21_po) | C++14 | 29 ms | 2408 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define X first
#define Y second
int n;
int ar[500005];
signed main(){
int ans=0;
cin>>n;
for(int i=1;i<=n;i++){
cin>>ar[i];
}
stack<int>stk;
for(int i=1;i<=n;i++){
while(stk.size()&&stk.top()>ar[i]){stk.pop();}
if(stk.size()&&stk.top()==ar[i]){continue;}
stk.push(ar[i]);
ans++;
}
cout<<ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |