1 条题解

  • 0
    @ 2026-10-25 15:22:53

    思路

    删除固定数量数位使字典序最小,处理重复位和单调序列。

    参考程序(C++11)

    #include <bits/stdc++.h>
    using namespace std;
    int main(){int t,k;string s;cin>>t;while(t--){cin>>s>>k;string a;for(char c:s){while(k&&!a.empty()&&a.back()>c){a.pop_back();k--;}a+=c;}a.resize(a.size()-k);cout<<a<<'\n';}}
    
    • 1

    信息

    ID
    1138
    时间
    1000ms
    内存
    64MiB
    难度
    普及−
    标签
    递交数
    1
    已通过
    1
    上传者