# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1153967 | salmon | Po (COCI21_po) | C++20 | 8 ms | 1096 KiB |
#include <bits/stdc++.h>
using namespace std;
int N;
int lst[100100];
vector<int> b;
int main(){
scanf(" %d",&N);
for(int i = 0; i < N; i++){
scanf(" %d",&lst[i]);
}
int cont = 0;
for(int i = 0; i < N; i++){
while(!b.empty() && b.back() > lst[i]){
b.pop_back();
cont++;
}
if(lst[i] == 0) continue;
if(b.empty() || b.back() != lst[i]) b.push_back(lst[i]);
}
cont += b.size();
printf("%d\n",cont);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |