Code
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define nl '\n'
int main() {
int t; cin >> t;
while(t--){
int n, k; cin >> n >> k;
string s; cin >> s;
map<int, int> vis;
map<char, vector<int>> mp;
for(int i=0;i<n;++i) mp[s[i]].push_back(i);
for(auto [x,y]: mp){
if(!k) break;
for(auto v: y) {
vis[v] = 1;
k--;
if(!k) break;
}
}
for(int i=0;i<n;++i) if(!vis[i]) cout << s[i];
cout << nl;
}
}
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 09:06:33
- Judged At
- 2024-10-30 09:06:33
- Judged By
- Score
- 0
- Total Time
- 3ms
- Peak Memory
- 532.0 KiB