社区讨论
$AT@@@所有大佬!!!80分求调$
P1823[COI 2007] Patrik 音乐会的等待参与者 2已保存回复 8
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 8 条
- 当前快照
- 1 份
- 快照标识符
- @mhj0ttcu
- 此快照首次捕获于
- 2025/11/03 18:52 4 个月前
- 此快照最后确认于
- 2025/11/03 18:52 4 个月前
#include<bits/stdc++.h>
using namespace std;
stack<int> a;
int s=0;
int n;
int main(){
cin>>n;
while(n--){
int x;
cin>>x;
int t=1;
while(!a.empty()&&a.top()<=x){
if(a.top()==x){
t++;
}
s++;
a.pop();
}
if(!a.empty()){
s++;
}
while(t--){
a.push(x);
}
}
cout<<s;
return 0;
}
回复
共 8 条回复,欢迎继续交流。
正在加载回复...