P2251 质量检测

题目描述

为了检测生产流水线上总共N件产品的质量,我们首先给每一件产品打一个分数A表示其品质,然后统计前M件产品中质量最差的产品的分值Q[m] = min{A1, A2, ... Am},以及第2至第M + 1件的Q[m + 1], Q[m + 2] ... 最后统计第N - M + 1至第N件的Q[n]。根据Q再做进一步评估。

请你尽快求出Q序列。

输入输出格式

输入格式:

输入共两行。

第一行共两个数N、M,由空格隔开。含义如前述。

第二行共N个数,表示N件产品的质量。

输出格式:

输出共N - M + 1行。

第1至N - M + 1行每行一个数,第i行的数Q[i + M - 1]。含义如前述。

输入输出样例

输入样例#1:

10 4
16 5 6 9 5 13 14 20 8 12
输出样例#1:

5
5
5
5
5
8
8

说明

[数据范围]

30%的数据,N <= 1000

100%的数据,N <= 100000

100%的数据,M <= N, A <= 1 000 000

//又一个板子
#include<iostream>
#include<cstdio>
#include<cstring>
#define maxn 1000001 using namespace std;
int a[maxn],f[maxn][],p[maxn];
int n,m,ans,cnt; inline int init()
{
int x=,f=;char c=getchar();
while(c>''||c<''){if(c=='-')f=-;c=getchar();}
while(c>=''&&c<=''){x=x*+c-'';c=getchar();}
return x*f;
} int main()
{
int l,r,k;
n=init();m=init();
for(int i=;i<=n;i++)
{
a[i]=init();
f[i][]=a[i];
}
for(int j=;j<=;j++)
for(int i=;i+(<<j)-<=n;i++)
f[i][j]=min(f[i][j-],f[i+(<<j-)][j-]);
for(int i=;i<=n;i++)
for(int j=;j<=;j++)
{
if(i<(<<j))
{
p[i]=j-;
break;
}
}
for(int i=m;i<=n;i++)
{
r=i;
l=i-m+;
k=p[r-l+];
ans=min(f[l][k],f[r-(<<k)+][k]);
printf("%d\n",ans);
}
return ;
}

P2251 质量检测(ST表)的更多相关文章

  1. 洛谷 P2251 质量检测(st表)

    P2251 质量检测 题目提供者ws_ly 标签 难度 普及/提高- 题目描述 为了检测生产流水线上总共N件产品的质量,我们首先给每一件产品打一个分数A表示其品质,然后统计前M件产品中质量最差的产品的 ...

  2. Luogu2251 质量检测 (ST表)

    我怎么开始划水了... #include <iostream> #include <cstdio> #include <cstring> #include < ...

  3. 洛谷 P2251 质量检测 题解

    P2251 质量检测 题目背景 无 题目描述 为了检测生产流水线上总共N件产品的质量,我们首先给每一件产品打一个分数A表示其品质,然后统计前M件产品中质量最差的产品的分值Q[m] = min{A1, ...

  4. 洛谷 P2251 质量检测

    题目背景 无 题目描述 为了检测生产流水线上总共N件产品的质量,我们首先给每一件产品打一个分数A表示其品质,然后统计前M件产品中质量最差的产品的分值Q[m] = min{A1, A2, ... Am} ...

  5. 【luogu P2251 质量检测】 题解

    也是一道ST表的板子题,很裸的RMQ问题,只需要在查询区间时处理一下下就好啦~ #include <cstdio> #include <algorithm> using nam ...

  6. 洛谷—— P2251 质量检测

    https://www.luogu.org/problemnew/show/P2251 题目背景 无 题目描述 为了检测生产流水线上总共N件产品的质量,我们首先给每一件产品打一个分数A表示其品质,然后 ...

  7. P2251 质量检测--洛谷luogu

    传送门 题目描述 为了检测生产流水线上总共N件产品的质量,我们首先给每一件产品打一个分数A表示其品质,然后统计前M件产品中质量最差的产品的分值Q[m] = min{A1, A2, ... Am},以及 ...

  8. [LUOGU] P2251 质量检测

    题目背景 无 题目描述 为了检测生产流水线上总共N件产品的质量,我们首先给每一件产品打一个分数A表示其品质,然后统计前M件产品中质量最差的产品的分值Q[m] = min{A1, A2, ... Am} ...

  9. 洛谷P2251 质量检测

    题目背景 无 题目描述 为了检测生产流水线上总共N件产品的质量,我们首先给每一件产品打一个分数A表示其品质,然后统计前M件产品中质量最差的产品的分值Q[m] = min{A1, A2, ... Am} ...

随机推荐

  1. Python&机器学习总结(二)

    ① Python中的Sort Python中的内建排序函数有 sort()和sorted()两个 list.sort(func=None, key=None, reverse=False(or Tru ...

  2. Shock wave

    ** shock wave thickness of shock wave is order of 1e-7 m why governed by Euler Equation? P334 shock ...

  3. POJ——1061 青蛙的约会

    青蛙的约会 Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 117858   Accepted: 24599 Descript ...

  4. 几道splay

    hdu 1890 题意:每次将第i位到第i小数字所在的位置之间的位置翻转,每次输出第i小数字所在的位置 分析: 简单的splay处理区间翻转问题 有三点需要注意: 1.区间是1~n+2 2.此题里的查 ...

  5. Spring Boot中使用Swagger2生成RESTful API文档(转)

    效果如下图所示: 添加Swagger2依赖 在pom.xml中加入Swagger2的依赖 <!-- https://mvnrepository.com/artifact/io.springfox ...

  6. [JavaEE] Injecting Bean

    So what is a Bean, in JavaEE, any class expect Entity are Bean. One usefully thing in Bean is Depend ...

  7. ZOJ 3675 Trim the Nails(bfs)

    Trim the Nails Time Limit: 2 Seconds      Memory Limit: 65536 KB Robert is clipping his fingernails. ...

  8. ssh远程连接出现someone counld be eavesdropping on you right now 的错误

    master主机通过ssh远程连接slaves机子时出现下述错误 解决的方法: 一.删除/root/.ssh/下的kown_hosts文件 二.在master机子上又一次运行scp id_dsa.pu ...

  9. LeetCode 725. Split Linked List in Parts (分裂链表)

    Given a (singly) linked list with head node root, write a function to split the linked list into k c ...

  10. 3.1 The Interpolating Polynomial(站点)

    Cubic Interpolation:                               https://www.youtube.com/watch? v=EtzlEA9MIwI Quad ...