Code
#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
int main()
{
ios_base:: sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
ll t;
cin>>t;
while(t--){
ll n, k;
cin>>n>>k;
string st;
cin>>st;
if(n==k){
cout<<'0'<<endl;
}
else{
ll arr[n];
vector<ll>arr2;
for(ll i=0; i<st.size(); i++){
ll tm= st[i]-'0';
arr[i]= tm;
arr2.push_back(tm);
}
sort(arr, arr+n);
ll arr3[k];
for(ll i=0; i<k; i++){
arr3[i]= arr[i];
}
for(ll i=0; i<k; i++){
for(ll j=n; j>=0 ; j--){
if(arr2[j]==arr3[i]){
arr2.erase(arr2.begin()+j);
break;
}
}
}
for(auto u:arr2){
cout<<u;
}
cout<<endl;
}
}
return 0;
}
Information
- Submit By
- Type
- Submission
- Problem
- P1006 Remove K Digits
- Contest
- Sylhet ICPC 2024 Collaborative Challenge: Episode 2
- Language
- C++17 (G++ 13.2.0)
- Submit At
- 2024-10-30 11:33:18
- Judged At
- 2024-11-11 02:34:52
- Judged By
- Score
- 0
- Total Time
- 2ms
- Peak Memory
- 560.0 KiB