暴力

#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std; #define MAXN 50010 int a[MAXN];
int X[MAXN],Y[MAXN],W[MAXN]; int C,N,Q,L; int read()
{
int x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
} int main()
{
N=read(),Q=read();
while(Q--)
{
int ty=read();
if (ty==1)
X[C]=read(),Y[C]=read(),W[C++]=read();
else
{
int xl=read(),yl=read(),xr=read(),yr=read(),k=read();
for (int i=L=0;i<C;i++)
if (xl<=X[i] && X[i]<=xr && yl<=Y[i] && Y[i]<=yr)
a[L++]=W[i];
if (k>L)
puts("NAIVE!ORZzyz.");
else
{
nth_element(a,a+(L-k),a+L);
printf("%d\n",a[L-k]);
}
}
}
return 0;
}

  

【bzoj4604】The kth maximum number的更多相关文章

  1. 【leetcode】668. Kth Smallest Number in Multiplication Table

    题目如下: 解题思路:几乎和[leetcode]719. Find K-th Smallest Pair Distance 的方法一样.只不过一个是减法一个是乘法,还有一点区别是[leetcode]7 ...

  2. 【leetcode】414. Third Maximum Number

    problem 414. Third Maximum Number solution 思路:用三个变量first, second, third来分别保存第一大.第二大和第三大的数,然后遍历数组. cl ...

  3. 【LeetCode】414. Third Maximum Number 解题报告(Python & C++)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 替换最大值数组 使用set 三个变量 日期 题目地址 ...

  4. BZOJ4604:The kth maximum number

    浅谈离线分治算法:https://www.cnblogs.com/AKMer/p/10415556.html 题目传送门:https://lydsy.com/JudgeOnline/problem.p ...

  5. 【LeetCode】779. K-th Symbol in Grammar 解题报告(Python)

    [LeetCode]779. K-th Symbol in Grammar 解题报告(Python) 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingz ...

  6. 【LeetCode】378. Kth Smallest Element in a Sorted Matrix 解题报告(Python)

    [LeetCode]378. Kth Smallest Element in a Sorted Matrix 解题报告(Python) 标签: LeetCode 题目地址:https://leetco ...

  7. 【CodeForces】889 C. Maximum Element 排列组合+动态规划

    [题目]C. Maximum Element [题意]给定n和k,定义一个排列是好的当且仅当存在一个位置i,满足对于所有的j=[1,i-1]&&[i+1,i+k]有a[i]>a[ ...

  8. 【LeetCode】230. Kth Smallest Element in a BST

    Difficulty: Medium  More:[目录]LeetCode Java实现 Description https://leetcode.com/problems/kth-smallest- ...

  9. 【贪心】codeforces D. Minimum number of steps

    http://codeforces.com/contest/805/problem/D [思路] 要使最后的字符串不出现ab字样,贪心的从后面开始更换ab为bba,并且字符串以"abbbb. ...

随机推荐

  1. 如果由你来设计 12306.cn,你会怎么设计?

    作者:huangkun链接:https://www.zhihu.com/question/20017917/answer/15272038来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业 ...

  2. ceph集群

    ceph集群部署 ceph理解: Ceph是一个分布式存储,可以提供对象存储.块存储和文件存储,其中对象存储和块存储可以很好地和各大云平台集成.其他具体介绍可见官网简介:http://docs.cep ...

  3. Redis 压缩存储的配置

    如题,redis是采用了ziplist 元素在不足一定数量时采用压缩存储 hash: zset: list: 如上图所示: ziplist-entries:最大元素数量(即存储了多少个元素) zipl ...

  4. Django之CBV和FBV

    Django之CBV和FBV CBV和FBV是C和F的区别: C是Class,F是Function 在请求中,有GET请求和POST请求. 在写CBV时,url是可以对应一个类的,在类中,分别写出GE ...

  5. html css笔记 -度一

    """浏览器 shell 内核外表 内心 IE tridentFirefox Geckogoogle chrome webkit/blinksafari webkitop ...

  6. 3.2.11 行 vs 字符串

        了解行(line)与字符串(string)的差异是相当重要的.大部分简易程序都是处理输入数据的行,像 grep 与 egrep,以及 sed 大部分的工作(99%)都是这样.在这些情况下,不会 ...

  7. jz2440烧写方法笔记

    1,jz2440用dnw烧写普通程序的步骤是: ①选择将uboot烧写到nor flash或者是nand flash中 ②打开dnw,选择要烧写的程序,注意不是uboot,是你要烧写的程序,他将所有的 ...

  8. 如何用photoshop输出html网页

    如何用photoshop输出html网页 首先得先对PSD文件做切片,有两种方法: ①使用工具栏上的"切片工具", 然后在图象上划出一块一块的区域. ②使用基于参考线的切片,按ct ...

  9. pip提示Did not provide a commend

    今天小编想要查看一下自己安装的pip版本,并且使用pip查看selenium版本等,结果在cmd输入pip,提示Did not provide a commend,如下所示: 在网上查询了很多方法,比 ...

  10. 用C# ASP.net将数据库中的数据表导出到Excel中

    需要用到组件GridView和一个button即可. 给GridView添加一个数据源, 选择你想要的数据库中的表的字段,添加成功后GridView中就显示数据. 再添加一个button,双击控件添加 ...