/ SeriousOJ /

Record Detail

Wrong Answer


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

Code

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll>vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef list<int> li;
typedef set<int> sti;
typedef map<int, int> mii;
typedef map<ll, ll> mll;
typedef unordered_map<int, int> umii;
typedef unordered_map<ll, ll> umll;
typedef unordered_set<ll> us;
typedef priority_queue<ll> pq;
typedef deque<ll> dq;
#define nl "\n"
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define Yes cout<<"YES\n";
#define No cout<<"NO\n";
#define yes cout<<"Yes\n";
#define no cout<<"No\n";
#define F first
#define sc second
#define all(v) v.begin(), v.end()
#define sortv(v) sort(v.begin(), v.end());
#define rsort(v) sort(v.rbegin(), v.rend());
#define revv(v) reverse(v.begin(), v.end());

const int N=1e6+9;
const int mod1=1e9+7, mod2=1e9+9;
const int base1=29, base2=67;
const long long int inf=1e18;
#define saiful_islam_bk

void solve(){
    
        ll n,k; cin>>n>>k;
        string s; cin>>s;
        if(n==k){
            cout<<0<<nl;
            return;
        }
        if(k==0) return void(cout<<s<<nl);
        for(ll i=1;i<s.size();i++)
        {
            if(k==0) break;
            if(s[i]>s[i-1]){
                s.erase(s.begin()+i-1);
                k--;
            }
        }
        ll i=s.size()-1;
        while(k){
            s.pop_back();
            k--;
        }
        cout<<s<<nl;
}
int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
    saiful_islam_bk
    ll test=1;
     cin>>test;
    for(ll ii=1; ii<=test; ii++){
        //cout<<"Case "<<ii<<": ";
        solve();
    }
}

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 12:06:12
Judged At
2024-11-11 02:34:45
Judged By
Score
0
Total Time
2ms
Peak Memory
320.0 KiB