/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Wrong Answer 2ms 320.0 KiB

Code

#include<bits/stdc++.h>
#define FileIO          freopen("input.in", "r", stdin); freopen("output.in", "w", stdout)
#define ll              long long
#define input_vec(v)    for(int II=0; II<v.size(); II++) cin >> v[II];
#define sortf(v)        sort(v.begin(), v.end());
#define sortr(v)        sort(v.rbegin(), v.rend());
#define print_vec(v)    for(int II=0; II<v.size(); II++){cout << v[II];} cout << endl;

using namespace std;

void test_case(int tc)
{
    int n, k;
    cin>>n>>k;
    string s;
    cin>>s;
    int len=s.size();
    if(n==k){
        cout<<0<<endl;
        return;
    }
    while(k){
        int minidx=0;
        for(int i=0;i<len;i++){
            if(s[i]!='*' && s[i]<s[minidx]){
                minidx=i;
            }
        }
        // cout<<"minindex: "<<minidx<<endl;
        //remove min index
        s[minidx]='*';
        k--;
    }
    for(int i=0;i<len;i++){
        if(s[i]!='*') cout<<s[i];
    }cout<<endl;
}

int main()
{
    
    //if(fopen("input.in", "r")) FileIO;
    int n; cin >> n;

    for(int i=0; i<n; i++) test_case(i+1);
}

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:13:02
Judged At
2024-11-11 02:35:26
Judged By
Score
0
Total Time
2ms
Peak Memory
320.0 KiB