Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <queue>
- #include <vector>
- #include <algorithm>
- #include <stack>
- using namespace std;
- #define Inf 0x3f3f3f3f
- #define mod 1e9+7
- char a[2000005];
- int n,k,l;
- char s[2000005];
- int main(){
- ios::sync_with_stdio(false);
- cin.tie(0);
- cout.tie(0);
- cin >> n >> k >> l;
- cin >> a;
- int dr = 0;
- for(int i = 0 ; i < n ; ++i){
- while(dr >= l && k && a[i] < s[dr - l]){
- dr = dr - l;
- k--;
- }
- s[dr++] = a[i];
- if(k == 0){
- int j = i + 1;
- while(j < n)
- s[dr++] = a[j++];
- break;
- }
- }
- if(k)
- dr = dr - k * l;
- s[dr] = '\0';
- cout << s;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement