P1106RE求救 代码如下:
#include<bits/stdc++.h>
using namespace std;
int n,m;
string s;
stack<int> q,w;
int main(){
ios::sync_with_stdio(false);
cin>>s;
cin>>m;
n=s.length();
n-=m;
for(int i=0;i<s.length();i++){
int x=s[i]-'0';
if(q.empty()||m==0){
q.push(x);
}else if(x<q.top()){
while(x<q.top()&&m&&!q.empty()){
m--;
q.pop();
}
q.push(x);
}else{
q.push(x);
}
}
while(!q.empty()){
w.push(q.top());
q.pop();
}
while(n&&!w.empty()){
cout<<w.top();
w.pop();
n--;
}
return 0;
}