zoukankan      html  css  js  c++  java
  • 【POJ2761】【区间第k大】Feed the dogs(吐槽)

    Description

    Wind loves pretty dogs very much, and she has n pet dogs. So Jiajia has to feed the dogs every day for Wind. Jiajia loves Wind, but not the dogs, so Jiajia use a special way to feed the dogs. At lunchtime, the dogs will stand on one line, numbered from 1 to n, the leftmost one is 1, the second one is 2, and so on. In each feeding, Jiajia choose an inteval[i,j], select the k-th pretty dog to feed. Of course Jiajia has his own way of deciding the pretty value of each dog. It should be noted that Jiajia do not want to feed any position too much, because it may cause some death of dogs. If so, Wind will be angry and the aftereffect will be serious. Hence any feeding inteval will not contain another completely, though the intervals may intersect with each other. 

    Your task is to help Jiajia calculate which dog ate the food after each feeding. 

    Input

    The first line contains n and m, indicates the number of dogs and the number of feedings. 

    The second line contains n integers, describe the pretty value of each dog from left to right. You should notice that the dog with lower pretty value is prettier. 

    Each of following m lines contain three integer i,j,k, it means that Jiajia feed the k-th pretty dog in this feeding. 

    You can assume that n<100001 and m<50001. 

    Output

    Output file has m lines. The i-th line should contain the pretty value of the dog who got the food in the i-th feeding.

    Sample Input

    7 2
    1 5 2 6 3 7 4
    1 5 3
    2 7 1
    

    Sample Output

    3
    2
    

    Source

    【分析】
    看到有人说用treap做区间第k大,我一惊,函数式treap!尼玛orzzz,然后一看题目,一看代码。
    题目(区间互不相交)——有用吗,尼玛?
    代码——把区间排序,一个个插进去,再一个个删掉,对于每个区间求一次区间第k大........
    卧槽,这也叫区间第k大!你在逗我。。。(╯‵□′)╯︵┻━┻
     
  • 相关阅读:
    秒杀多线程第八篇 经典线程同步 信号量Semaphore
    SURF特征
    (最短路径算法整理)
    中国大推力矢量发动机WS15 跨入 世界先进水平!
    SQL Profile 总结(一)
    Spring下@ResponseBody响应中文内容乱码问题
    Ubuntu12.04下jamvm1.5.4+classpath-0.98成功执行 helloworld.class
    【2012.1.24更新】不要再在网上搜索eclipse的汉化包了!
    [数据结构] N皇后问题
    DG之主库、备库切换(物理备库)
  • 原文地址:https://www.cnblogs.com/hoskey/p/4329284.html
Copyright © 2011-2022 走看看