Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as C by selina24228 ( 8 years ago )
#include<stdio>
#include<string>
char number[100000001];
char stack[100000001];
char cpy[100000001];
int main(){
    int k;
    scanf("%s%d",number,&k);
    int len=strlen(number);
    int top=0,popout=0;
    for(int i=0;i<len if(number[i]!='0' while(top!=0&&stack[top-1]>number[i]){
                if(popout>=k) break;
                top--;
                popout++;
            }
            if(top!=0&&stack[top-1]=='0'){
                if(stack[0]>number[i]&&(popout+top)<=k&&(len-i>len-k-1)){
                    top=0;
                    popout+=top;
                }
            }
            stack[top]=number[i];
            top++;
        }
        else{
            while(top!=1&&stack[top-1]>number[i]){
                if(popout>=k) break;
                top--;
                popout++;
            }
            stack[top]=number[i];
            top++;
        }
    }
    strncpy(cpy,stack,len-k);
    printf("%s\n",cpy);
    return 0;
}

 

Revise this Paste

Your Name: Code Language: