(补题,妈蛋那时候大哥给我说是尺取,我不想打…真是艾斯比了…)

题意:

退役狗 NanoApe 滚回去学文化课啦!

在数学课上,NanoApe 心痒痒又玩起了数列。他在纸上随便写了一个长度为 n 的数列,他又根据心情写下了一个数 m。

他想知道这个数列中有多少个区间里的第 k 大的数不小于 m,当然首先这个区间必须至少要有 k个数啦。

思路:

首先就是大于m阿,然后,然后再去判断一下在区间内的大于m个的数有没有大于k,大于的话就保证这个区间包括后面所有都可以满足题目条件。。很水的尺取。。。

贴一发挫code…….

#include <iostream>
#include <cstdio>
#include<vector>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long LL; const int N=2e5+10;
int a[N];
int s,e,cnt;
int n,m,k; int main()
{
int t;
scanf("%d",&t);
while(t--)
{
scanf("%d%d%d",&n,&m,&k);
for(int i=1;i<=n;i++)
scanf("%d",&a[i]); LL ans=0;
cnt=e=0; for(s=1;s<=n;s++)
{
while(cnt<k&&e<=n)
{
if(a[++e]>=m)
cnt++;
}
if(cnt>=k)
ans+=n-e+1;
if(a[s]>=m)
--cnt;
}
printf("%lld\n",ans);
}
return 0;
}

​​

hdoj5806【尺取】的更多相关文章

  1. Gym 100703I---Endeavor for perfection(尺取)

    题目链接 http://codeforces.com/problemset/gymProblem/100703/I Description standard input/outputStatement ...

  2. NOJ 1072 The longest same color grid(尺取)

    Problem 1072: The longest same color grid Time Limits:  1000 MS   Memory Limits:  65536 KB 64-bit in ...

  3. hdu 4123 Bob’s Race 树的直径+rmq+尺取

    Bob’s Race Time Limit: 5000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Probl ...

  4. Codeforces Round #116 (Div. 2, ACM-ICPC Rules) E. Cubes (尺取)

    题目链接:http://codeforces.com/problemset/problem/180/E 给你n个数,每个数代表一种颜色,给你1到m的m种颜色.最多可以删k个数,问你最长连续相同颜色的序 ...

  5. poj2566尺取变形

    Signals of most probably extra-terrestrial origin have been received and digitalized by The Aeronaut ...

  6. poj2100还是尺取

    King George has recently decided that he would like to have a new design for the royal graveyard. Th ...

  7. hdu 6231 -- K-th Number(二分+尺取)

    题目链接 Problem Description Alice are given an array A[1..N] with N numbers. Now Alice want to build an ...

  8. Codeforces 939E Maximize! (三分 || 尺取)

    <题目链接> 题目大意:给定一段序列,每次进行两次操作,输入1 x代表插入x元素(x元素一定大于等于之前的所有元素),或者输入2,表示输出这个序列的任意子集$s$,使得$max(s)-me ...

  9. cf1121d 尺取

    尺取,写起来有点麻烦 枚举左端点,然后找到右端点,,使得区间[l,r]里各种颜色花朵的数量满足b数组中各种花朵的数量,然后再judge区间[l,r]截取出后能否可以供剩下的n-1个人做花环 /* 给定 ...

随机推荐

  1. [WASM] Create a New Rust/Webpack Project using the rust-webpack Template

    Previous to this post, we set up our own Rust/wasm project from scratch. The Rust/wasm team ships a ...

  2. window.onresize 事件笔记

     1.浏览器尺寸变化响应事件 : window.onresize = function(){....} 这里须要注意的是,onresize响应事件处理中.获取到的页面尺寸參数是变更后的參数. // ...

  3. Android命令行下蓝牙使用

    注意:此部分仅仅适用于broadcom 系列蓝牙芯片,比如RK903, AP6xxx 系列 通过su 命令切换到root 用户 1.先确认RFKILL 驱动已经载入 ls /sys/class/rfk ...

  4. 使用 C# 开发智能手机软件:推箱子(四)

    这是"使用 C# 开发智能手机软件:推箱子"系列文章的第四篇. 在这篇文章中,介绍 Common/FindPath.cs 源程序文件. using System; using Sy ...

  5. 第一次OllyDbg逆向记录(分析思路和注意点&其他文章)

    OllyDbg 操作菜单栏.工具栏.快捷键 C++调用加强 目录 OllyDbg 操作菜单栏.工具栏.快捷键    1 一.    载入观察    1 1.静态载入观察:    1 2.OD动态观察  ...

  6. 初学c的一点体会

    自学C语言的一些体会1 从最初什么都不知道变成知道一点,一转眼就过去了三个多月,最开始只是刚进大学,感觉太闲了不太好就决定学点什么,于是就到图书馆逛了一圈找找看有什么有趣的书可以看看,刚好就在书架上看 ...

  7. ActionFilterAttribute之HtmlFilter,压缩HTML代码

    当开启这个过滤器后,最终生成的HTML代码将会被压缩一下,在流量很大的网站中,能减少带宽成本就减少一点,何乐而不为? [csharp] view plaincopy using System; usi ...

  8. MYSQL强制使用索引和禁止使用索引

    mysql强制索引和禁止某个索引 1.mysql强制使用索引:force index(索引名或者主键PRI) 例如: select * from table force index(PRI) limi ...

  9. Cooperating sequential processes》,这篇论文提出了大名鼎鼎的概念信号量,Java里面用于线程同步的wait/notify也是信号量的一种实现。

    闲话高并发的那些神话,看京东架构师如何把它拉下神坛 https://mp.weixin.qq.com/s/lAqn8CfSRta9iSvOR1Le6w

  10. De Moivre–Laplace theorem 掷硬币

    De Moivre–Laplace theorem - Wikipedia https://en.wikipedia.org/wiki/De_Moivre%E2%80%93Laplace_theore ...