提交时间:2023-11-02 13:28:17

运行 ID: 108350

#include<bits/stdc++.h> using namespace std; int a[114514]; vector <int> vec; int main(){ int n,k,lst = 1; bool qdl = true; string s; cin>>s>>k; n = s.size(); if (k >= n){ cout<<0; return 0; } int x = n - k; for (int i = 1;i <= n;i++){ a[i] = s[i - 1] - '0'; } int maxi = 0; while (x > 0){ int maxn = 1919810; for (int i = maxi + 1;i <= n - x + 1;i++){ if (a[i] < maxn){ maxn = a[i]; maxi = i; } } vec.push_back(a[maxi]); x--; } if (vec.size() == 0){ vec.push_back(0); } qdl = false; for (int i = 0;i < vec.size();i++){ if (qdl && vec[i] == 0 && i != vec.size() - 1){ continue; } cout<<vec[i]; qdl = false; } return 0; }