提交时间:2023-12-31 15:47:09
运行 ID: 227899
#include <bits/stdc++.h> using namespace std; int main() { string str; int n,t,max=0; bool l=0; cin >> str; cin >> n; t=n; for (int i=0;i<str.size();i++) { if (str[i]>str[i+1]&&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=0;i<str.size();i++) { if (str[i]!='?') { cout << str[i]; l=1; } } if (l==0) { cout << 0; } return 0; }