Submission #1154195

#TimeUsernameProblemLanguageResultExecution timeMemory
1154195THXuanPo (COCI21_po)C++20
10 / 70
6 ms1348 KiB
#include <iostream> #include <vector> #include <algorithm> #include <cstring> #include <string> #include <array> #include <cmath> #include <stack> #include <queue> #include <map> #include <set> #define INF 1e9 using namespace std; typedef long long ll; const ll MOD = 1000000007; const ll MAXN = 300005; void solve() { int n; cin >> n; vector<ll>v(n); for (int i = 0; i < n; i++)cin >> v[i]; int ans = 1; stack<int>stk; for (int i = 0; i < n + 1; i++) { while (stk.size() && stk.top() >= v[i]) { if (stk.top() > v[i])++ans; stk.pop(); } stk.push(v[i]); } cout << ans << "\n"; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t = 1;// cin>>t; while (t--) solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...