Copyright: For reprint, whisper bloggers https://blog.csdn.net/lylzsx20172018/article/details/91460661
Topic links : https://cn.vjudge.net/contest/305866#problem/H
idea : can not string from small to large, that can not break the original order, delete k characters, guaranteed to be the smallest, which is to ensure strings are incremental to, the increment is not a character deleted, the next one instead.
Sample Input
2
9128456 2
1444 3
Sample Output
12456
1
Code :
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){
int T;
scanf("%d",&T);
char st[1000];
int k,len;
while(T--){
scanf("%s %d",st,&k);
len=strlen(st);
for(int n=0; n<k; n++){
for(int i=0; i<len-1; i++){
if(st[i]>st[i+1]){
for(int j=i+1; j<len; j++)
st[j-1]=st[j];
}
}
}
for(int i=0;i<len-k;i++)
printf("%c",st[i]);
printf("\n");
}
return 0;
}