Code
#include<bits/stdc++.h>
using namespace std;
int main(){
int t;
cin>>t;
while(t--){
int n,k;
cin>>n>>k;
string s;
cin>>s;
vector<char>st;
int rem=k;
for(char c:s){
while(!st.empty()&&rem>0&&st.back()<c){
st.pop_back();
rem--;
}
st.push_back(c);
}
while(rem>0){
st.pop_back();
rem--;
}
if(n==k){
cout<<0<<"\n";
}
else{
for(char c:st){
cout<<c;
}
cout<<"\n";
}
}
}
Information
- Submit By
- Type
- Submission
- Problem
- P1006 A. Remove K Digits
- Language
- C++11 (G++ 13.2.0)
- Submit At
- 2025-08-04 06:47:36
- Judged At
- 2025-08-04 06:47:36
- Judged By
- Score
- 100
- Total Time
- 2ms
- Peak Memory
- 532.0 KiB