답안 #898529

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
898529 2024-01-04T20:43:14 Z vjudge1 Po (COCI21_po) C++17
70 / 70
36 ms 1572 KB
#include<bits/stdc++.h>
using namespace std;
int main() {
    int n, ans = 0;
    cin >> n;
    stack<int> s;
    for(int i = 0; i < n; i++) {
        int x;
        cin >> x;
        while(s.size()&&s.top()>x)
            s.pop();
        if(s.size()&&s.top()==x)
            continue;
        if(x)
            ans++,s.push(x);
    }
    cout << ans << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 428 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 7 ms 604 KB Output is correct
5 Correct 10 ms 600 KB Output is correct
6 Correct 30 ms 1572 KB Output is correct
7 Correct 36 ms 1300 KB Output is correct