제출 #1153781

#제출 시각아이디문제언어결과실행 시간메모리
1153781YSH2020Po (COCI21_po)C++20
70 / 70
23 ms1608 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
  int n; cin >> n;
  int a[n+1]; for (int i = 0; i < n; i++) cin >> a[i];
  a[n] = 0;
  stack<int> x;
  int ans = 0;
  for (int i = 0; i < n+1; i++) {
    while (x.size() > 0 and x.top() >= a[i]) {
      if (x.top() != a[i]) ans += 1;

      x.pop();
    }
    x.push(a[i]);
  }
  cout << ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...