Submit Time:2023-12-31 16:32:55
运行 ID: 227951
#include <bits/stdc++.h> using namespace std; int main(){ string str; int n,t,max=0; bool l=0; cin >> str >>n; t=n; for (int i=0;i<str.size()-1;i++) { if (str[i+1]<str[i]) { while (str[i+1]<str[i]&&t>0) { str[i]='?'; t--; } } } if (t!=1) { for (int j=0;t>0;j++) { for (int i=0;i<str.size();i++) { if (str[i]!='?'&&str[i]>max) { max=i; } } str[max]='?'; t--; } } for (int i=1;str[i]!='?'&&str[i]!='0';i++) { if (str[i]=='0') { str[i]='?'; } } for(int i=0;i<str.size();i++) { if (str[i]!='?') { cout << str[i]; l=1; } } if (l==0) { cout << '0'; } return 0; }