Submission #540548

#TimeUsernameProblemLanguageResultExecution timeMemory
540548glomePo (COCI21_po)C++17
20 / 70
10 ms980 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<int> y(n); for (int i = 0; i<n; i++) { cin >> y[i]; } stack<int> q; q.push(-1); int ans = -1; for (int i = 0; i<n; i++) { while(q.top() > y[i]) { ans++; q.pop(); } if(y[i] != q.top()) q.push(y[i]); } cout << ans + q.size() << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...