1 条题解
-
0
单调栈严格删除s位,清除前导零并在全零时输出0。
#include <bits/stdc++.h> using namespace std; int main(){ios::sync_with_stdio(false);cin.tie(nullptr); string digits;int s;cin>>digits>>s;string answer;for(char ch:digits){while(s&&!answer.empty()&&answer.back()>ch){answer.pop_back();s--;}answer+=ch;}if(s)answer.resize(answer.size()-s);auto p=answer.find_first_not_of('0');cout<<(p==string::npos?"0":answer.substr(p))<<"\n"; return 0; }
- 1
信息
- ID
- 3996
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 5
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者