记录编号 |
165874 |
评测结果 |
AAAAAAAAA |
题目名称 |
[POJ 2823]滑动窗口 |
最终得分 |
100 |
用户昵称 |
zys |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.897 s |
提交时间 |
2015-06-13 10:28:25 |
内存使用 |
7.94 MiB |
显示代码纯文本
- #include<cstdio>
- #include<queue>
- using namespace std;
- struct MAx{
- int bh,w;
- friend bool operator < ( MAx a,MAx b )
- {
- return a.w < b.w;
- }
- };
- MAx c1;
- struct MIn{
- int bh,w;
- friend bool operator < ( MIn a,MIn b )
- {
- return a.w > b.w;
- }
- };
- MIn c2;
- priority_queue<MAx> Max;
- priority_queue<MIn> Min;
- int n,k,a,b,MAX[1000000],MIN[1000000],tot;
- int main()
- {
- freopen("window.in","r",stdin);
- freopen("window.out","w",stdout);
- scanf("%d%d",&n,&k);
- for(int i=1;i<=k;i++)
- {
- scanf("%d",&a);
- c1.bh=i;
- c1.w=a;
- c2.bh=i;
- c2.w=a;
- Max.push(c1);
- Min.push(c2);
- }
- MAX[++tot]=Max.top().w;
- MIN[tot]=Min.top().w;
- for(int i=k+1;i<=n;i++)
- {
- scanf("%d",&a);
- c1.bh=i;
- c1.w=a;
- c2.bh=i;
- c2.w=a;
- Max.push(c1);
- Min.push(c2);
- while(Max.top().bh<=tot)
- Max.pop();
- while(Min.top().bh<=tot)
- Min.pop();
- MAX[++tot]=Max.top().w;
- MIN[tot]=Min.top().w;
- }
- for(int i=1;i<=tot;i++)
- printf("%d ",MIN[i]);
- printf("\n");
- for(int i=1;i<=tot;i++)
- printf("%d ",MAX[i]);
- // while(1);
- }