暴力

  1. #include<algorithm>
  2. #include<iostream>
  3. #include<cstdlib>
  4. #include<cstring>
  5. #include<cstdio>
  6. #include<cmath>
  7. using namespace std;
  8.  
  9. #define MAXN 50010
  10.  
  11. int a[MAXN];
  12. int X[MAXN],Y[MAXN],W[MAXN];
  13.  
  14. int C,N,Q,L;
  15.  
  16. int read()
  17. {
  18. int x=0,f=1;char ch=getchar();
  19. while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
  20. while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
  21. return x*f;
  22. }
  23.  
  24. int main()
  25. {
  26. N=read(),Q=read();
  27. while(Q--)
  28. {
  29. int ty=read();
  30. if (ty==1)
  31. X[C]=read(),Y[C]=read(),W[C++]=read();
  32. else
  33. {
  34. int xl=read(),yl=read(),xr=read(),yr=read(),k=read();
  35. for (int i=L=0;i<C;i++)
  36. if (xl<=X[i] && X[i]<=xr && yl<=Y[i] && Y[i]<=yr)
  37. a[L++]=W[i];
  38. if (k>L)
  39. puts("NAIVE!ORZzyz.");
  40. else
  41. {
  42. nth_element(a,a+(L-k),a+L);
  43. printf("%d\n",a[L-k]);
  44. }
  45. }
  46. }
  47. return 0;
  48. }

  

【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. 2019浙师大校赛(浙大命题)(upc复现赛)总结

    2019浙师大校赛(浙大命题)(upc复现赛)总结 早上九点开始.起得迟了,吃了早饭慌慌张张跑过去,刚到比赛就开始了. 开始分别从前往后和从后往前看题,一开始A题,第一发WA,第二次读题发现漏看了还有 ...

  2. [Python3网络爬虫开发实战] 3.3-正则表达式

    本节中,我们看一下正则表达式的相关用法.正则表达式是处理字符串的强大工具,它有自己特定的语法结构,有了它,实现字符串的检索.替换.匹配验证都不在话下. 当然,对于爬虫来说,有了它,从HTML里提取想要 ...

  3. configparser logging

    configparser模块 # 该模块适用于配置文件的格式与windows ini文件类似,可以包含一个或多个节(section),每个节可以有多个参数(键=值). import configpar ...

  4. 动态创建div(鼠标放上显示二维码)

    最近的微信大行其道.各个网站上都给出的微信验证码,进行手机扫描加入. 怎么创建类似与点击鼠标弹出一个浮动的div显示二维码的这种效果. 1.首先制作好这样的图片,写css样式 <style ty ...

  5. jQuery入门--- 非常好

    jQuery入门------https://blog.csdn.net/dkh_321/article/details/78093788

  6. COJ 1163 乘法逆元的求解

    乘法逆元就是求一个 a/b = c(mod m)在已知a%m , b%m 的条件下 求c的解 #include <cstdio> #include <cstring> usin ...

  7. Python模块:configparser、hashlib、(subprocess)

    configparser模块: 此模块用于生成和修改常见配置文档. 一个常见配置文件(.ini的后缀名)格式如下: [DEFAULT] # DEFAULT 是指后面的字典里都会默认有的内容 Serve ...

  8. [NOIP2004] 提高组 洛谷P1089 津津的储蓄计划

    题目描述 津津的零花钱一直都是自己管理.每个月的月初妈妈给津津300元钱,津津会预算这个月的花销,并且总能做到实际花销和预算的相同. 为了让津津学习如何储蓄,妈妈提出,津津可以随时把整百的钱存在她那里 ...

  9. 【NOIP2017练习】溢出(模拟)

    题意: 思路: a*b<=c <====> b<=c div a var ch,maxs,s:ansistring; v,k,i,maxl,l,len,cnt,cas:long ...

  10. hdu_2082_找单词_201404271536

    找单词 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submiss ...