Submission #366341

#TimeUsernameProblemLanguageResultExecution timeMemory
366341CodePlatinaPo (COCI21_po)C++14
20 / 70
13 ms1132 KiB
#include <iostream> #include <vector> #include <algorithm> #include <utility> #define pii pair<int, int> #define piii pair<int, pii> #define pll pair<long long, long long> #define plll pair<long long, pll> #define ff first #define ss second #define ee ss.ff #define rr ss.ss #define DEBUG using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; int arr[n]; for(auto &i : arr) cin >> i; vector<int> Q; int ans = 0; for(int i = 0; i < n; ++i) { while(Q.size() && Q.back() > arr[i]) Q.pop_back(), ++ans; if(Q.empty() || Q.back() != arr[i]) Q.push_back(arr[i]); } cout << ans + Q.size(); }
#Verdict Execution timeMemoryGrader output
Fetching results...