//紫书P253 奖品的价值
//Serene
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<string>
#include<cstdio>
#include<cmath>
#include<deque>
using namespace std;
const int maxn=1e5+10;
int n,d,r;
int a[maxn];
deque<int> Q;
int aa;char c;
int read() {
aa=0;c=getchar();
while(c<'0'||c>'9') c=getchar();
while(c>='0'&&c<='9') aa=aa*10+c-'0',c=getchar();
return aa;
}
int main() {
string g;
n=read();d=read();
int pos;
while(n) {
getline(cin,g);
Q.clear();
for(int i=0;i<g.length();++i) a[i+1]=g[i]-'0';
Q.push_back(1);pos=1;r=d+1;
for(int i=1;i<=n-d;++i) {
while(pos!=r) {
pos++;
while(!Q.empty()&&a[Q.back()]<a[pos]) Q.pop_back();
Q.push_back(pos);
}
printf("%d",a[Q.front()]);
Q.pop_front();r++;
}
printf("\n");
n=read();d=read();
}
return 0;
}
奖品的价值 Erasing and Winning
最新推荐文章于 2018-12-16 20:11:28 发布