/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Wrong Answer 1ms 324.0 KiB

Code

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define ld long double
#define ull unsigned long long
#define lcm(a,b) ((a*b)/__gcd(a,b))
const int MOD = 1000000007;

void solve(){
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;

    if (n == k){
        cout << 0 << endl;
        return;
    }

    for (int i = 0; i < n-1; i++){
        if(!k) break;
        if (s[i] < s[i + 1]){
            s.erase(i, 1);
            k--;
            i = 0;
        }
    }  

    while(k--) s.pop_back();
    cout << s << endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int t;
    cin >> t;

    while(t--){
        solve();
    }    
}

Information

Submit By
Type
Submission
Problem
P1006 Remove K Digits
Language
C++17 (G++ 13.2.0)
Submit At
2024-11-02 06:16:41
Judged At
2024-11-11 02:34:15
Judged By
Score
0
Total Time
1ms
Peak Memory
324.0 KiB