Submission #367102

# Submission time Handle Problem Language Result Execution time Memory
367102 2021-02-16T09:56:15 Z ritul_kr_singh Po (COCI21_po) C++17
20 / 70
12 ms 1516 KB
//#pragma GCC optimize("Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define sp << " " <<
#define nl << "\n"

signed main(){
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    int n; cin >> n;
    int a[n], ans = 0;
    for(int& i : a) cin >> i;

    stack<int> s;

    for(int i=0; i<n; ++i){
        while(!s.empty() and s.top() > a[i]){
            s.pop();
            ++ans;
        }
        if(s.empty() or s.top() < a[i]) s.push(a[i]);
    }
    while(!s.empty()){
        s.pop();
        ++ans;
    }
    cout << ans nl;
}
# Verdict Execution time Memory 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 5 ms 768 KB Output isn't correct
5 Incorrect 6 ms 876 KB Output isn't correct
6 Correct 12 ms 1516 KB Output is correct
7 Incorrect 12 ms 1152 KB Output isn't correct