Submission #782687

# Submission time Handle Problem Language Result Execution time Memory
782687 2023-07-14T07:40:04 Z 1075508020060209tc Po (COCI21_po) C++14
20 / 70
29 ms 2408 KB
#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
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Incorrect 7 ms 724 KB Output isn't correct
5 Incorrect 10 ms 980 KB Output isn't correct
6 Correct 29 ms 2408 KB Output is correct
7 Incorrect 28 ms 1964 KB Output isn't correct