답안 #371045

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
371045 2021-02-25T16:43:11 Z neki Po (COCI21_po) C++14
70 / 70
46 ms 1764 KB
#include <bits/stdc++.h>
#define ll long long
#define loop(i, a, b) for(ll i=a;i<b;i++)
#define pool(i, a, b) for(ll i=a-1;i>=b;i--)
#define fore(i, a) for(auto&& i:a)
#define fi first
#define se second
#define ps(a) push_back(a)
#define pb(a) pop_back(a)
#define sc scanf
#define vc vector
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(), a.end()
#define llmax LLONG_MAX/2
#define llmin -LLONG_MAX/2
using namespace std;
#define mn 500100
#define par pair<ll, ll>
#define ld long double
#define mod 1000000007
 

 
int main() {
    ll n, ans=0;cin >> n;
    vc<ll> st;st.ps(0);
    loop(i, 0, n){
        ll t;cin >> t;
        while(st.back()>t) st.pop_back();
        if(st.back()== t) ans+=0;
        else ans++, st.ps(t);
    }
    cout << ans << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 10 ms 492 KB Output is correct
5 Correct 15 ms 492 KB Output is correct
6 Correct 46 ms 1764 KB Output is correct
7 Correct 41 ms 1260 KB Output is correct