# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1153829 | WongYiKai | Po (COCI21_po) | C++20 | 6 ms | 840 KiB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll n;
cin >> n;
ll mn = 2000000000;
stack<ll> s;
ll count=0;
for (int i=0;i<n;i++){
ll curr;
cin >> curr;
mn = min(mn,curr);
while (!s.empty() && s.top()>curr) {
count++;
s.pop();
}
if (s.empty() || s.top() != curr) s.push(curr);
}
count += s.size();
if (mn==0) count--;
cout << count;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |