Start: Jul, 05, 2019 08:40:00
2019年度暑期短学期达标测试
End: Jul, 05, 2019 11:40:00
Time elapsed:
Time remaining:

Problem_ID: G
Result: Accepted
Time: 472ms
Memory: 1120kB
Author: CT12811591281
In contest: 1281

#include<stdio.h>
#include<string.h>
int main(){
	int a,long1;
	int i,j,k,c,l;
	char str[10010],de;
	while(~scanf("%s %d",str,&a)){
		c=0;
		long1=strlen(str);
		for(j=0;j<long1-1;j++){
			if(str[j]<str[j+1]&&c<a){
				de=str[j];
				for(k=j;k<long1-1;k++){
					str[k]=str[k+1];
				}
				str[long1-1]='\0';
				long1--;
				c++;
				j--;
				for(l=j;l>=0;l--){
					if(str[l]==de&&c<a){
						for(k=l;k<long1-1;k++){
							str[k]=str[k+1];
						}
						str[long1-1]='\0';
						long1--;
						c++;
						j--;
					}
					else if(str[l]!=de){
						j--;
						break;
					}
				} 
			}
		}
		if(c<a){
			i=a-c;
			str[long1-i]='\0';
		}
		printf("%s\n",str);
	}
}