提交时间:2024-08-21 16:32:34
运行 ID: 180612
#include <bits/stdc++.h> using namespace std; int x,n,ans; stack<int>s; int main() { cin>>n; while (n--) { cin>>x;int t=1; while (s.size() && x>=s.top()) { if (s.top()==x)t++; ans++;s.pop(); } if (s.size())ans++; while (t--)s.push(x); } cout<<ans; return 0; }