제출 #375153

#제출 시각아이디문제언어결과실행 시간메모리
375153AdiZer0Po (COCI21_po)C++17
70 / 70
14 ms1132 KiB
#include <bits/stdc++.h>

#define pb push_back
#define whole(x) x.begin(), x.end()
#define sz(x) (int)x.size()

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = (int)1e5 + 8;
const int INF = (int)1e9 + 7;
const ll linf = (ll)1e15 + 2;

int n, a[N];
int main() { 
    scanf ("%d", &n);
    for (int i = 1; i <= n; ++i) scanf ("%d", a + i);
    vector<int> v;
    int cnt = 0;
    for (int i = 1; i <= n; ++i) {
        if (!v.empty()) { 
            if (v.back() == a[i]) continue;
            while (!v.empty() && v.back() > a[i]) v.pop_back();
        }
        if (a[i] != 0 && (v.empty() || v.back() < a[i])) ++cnt, v.pb(a[i]);
    }
    printf ("%d\n", cnt);
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'int main()':
Main.cpp:18:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   18 |     scanf ("%d", &n);
      |     ~~~~~~^~~~~~~~~~
Main.cpp:19:40: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   19 |     for (int i = 1; i <= n; ++i) scanf ("%d", a + i);
      |                                  ~~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...