P3567 [POI2014]KUR-Couriers

    • 418通过
    • 1.2K提交
  • 题目提供者 洛谷OnlineJudge
  • 评测方式 云端评测
  • 标签 主席树 可持久化 线段树 POI 2014 高性能
  • 难度 省选/NOI-
  • 时空限制 1000ms / 256MB

题解

  • 提示:收藏到任务计划后,可在首页查看。
  • 最新讨论 显示

    推荐的相关题目 显示

    题目描述

    Byteasar works for the BAJ company, which sells computer games.

    The BAJ company cooperates with many courier companies that deliver the games sold by the BAJ company to its customers.

    Byteasar is inspecting the cooperation of the BAJ company with the couriers.

    He has a log of successive packages with the courier company that made the delivery specified for each package.

    He wants to make sure that no courier company had an unfair advantage over the others.

    If a given courier company delivered more than half of all packages sent in some period of time, we say that it dominated in that period.

    Byteasar wants to find out which courier companies dominated in certain periods of time, if any.

    Help Byteasar out!

    Write a program that determines a dominating courier company or that there was none.

    给一个数列,每次询问一个区间内有没有一个数出现次数超过一半

    输入输出格式

    输入格式:

    The first line of the standard input contains two integers, and (), separated by a single space, that are the number of packages shipped by the BAJ company and the number of time periods for which the dominating courier is to be determined, respectively.

    The courier companies are numbered from to (at most) .

    The second line of input contains integers, (), separated by single spaces; is the number of the courier company that delivered the -th package (in shipment chronology).

    The lines that follow specify the time period queries, one per line.

    Each query is specified by two integers, and (), separated by a single space.

    These mean that the courier company dominating in the period between the shipments of the -th and the -th package, including those, is to be determined.

    In tests worth of total score, the condition holds, and in tests worth of total score .

    输出格式:

    The answers to successive queries should be printed to the standard output, one per line.

    (Thus a total of lines should be printed.) Each line should hold a single integer: the number of the courier company that dominated in the corresponding time period, or if there was no such company.

    输入输出样例

    输入样例#1: 复制
    7 5
    1 1 3 2 3 4 3
    1 3
    1 4
    3 7
    1 7
    6 6
    
    输出样例#1: 复制
    1
    0
    3
    0
    4
    

    说明

    给一个数列,每次询问一个区间内有没有一个数出现次数超过一半

    提示
    标程仅供做题后或实在无思路时参考。
    请自觉、自律地使用该功能并请对自己的学习负责。
    如果发现恶意抄袭标程,将按照I类违反进行处理。