Run ID | Author | Problem | Lang | Verdict | Score | Time | Memory | Code Length | Submit Time |
---|---|---|---|---|---|---|---|---|---|
227899 | 顾欣薇 | 基础算法-贪心算法:删除问题 | C++ | Wrong Answer | 20 | 0 MS | 276 KB | 553 | 2023-12-31 15:47:09 |
#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; }