답안 #486136

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
486136 2021-11-10T15:31:28 Z davi_bart Po (COCI21_po) C++14
70 / 70
9 ms 1744 KB
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define fi first
#define se second
#define ld long double
#define pb push_back
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<int> v(N);
    vector<int> k;
    int ans = 0;
    for (int &i : v) {
        cin >> i;
        while (k.size() && k.back() > i) k.pop_back();
        if (i == 0) continue;
        if (!k.size() || k.back() != i) {
            ans++;
            k.pb(i);
        }
    }
    cout << ans << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 3 ms 716 KB Output is correct
5 Correct 5 ms 844 KB Output is correct
6 Correct 9 ms 1744 KB Output is correct
7 Correct 9 ms 1100 KB Output is correct