HAYBALE - Haybale stacking

题意翻译

话说这也是USACO 2013 Nov Bronze的题目stacking Feeling sorry for all the mischief she has caused around the farm recently, Bessie has agreed to help Farmer John stack up an incoming shipment of hay bales. She starts with N (1 <= N <= 1,000,000, N odd) empty stacks, numbered 1..N. FJ then gives her a sequence of K instructions (1 <= K <= 25,000), each of the form "A B", meaning that Bessie should add one new haybale to the top of each stack in the range A..B. For example, if Bessie is told "10 13", then she should add a haybale to each of the stacks 10, 11, 12, and 13. After Bessie finishes stacking haybales according to his instructions, FJ would like to know the median height of his N stacks -- that is, the height of the middle stack if the stacks were to be arranged in sorted order (conveniently, N is odd, so this stack is unique). Please help Bessie determine the answer to FJ's question. 贝茜为最近在农场附近造成的种种灾难感到难过,她同意帮助农场主约翰把一批干草捆起来。 一开始有N(1 <= N <= 1,000,000, N 是奇数)个空堆,编号为1..N。FJ给出了K (1 <= K <= 25,000)条指令,格式为“A B"的形式,意思是贝茜要添加一包新的干草到范围为A..B的干草堆顶。例如,如果贝茜的指令是”10 13“,那么她要给10,11,12和13这些干草堆添加一包干草。 在贝茜完成了所有干草堆的指令后,FJ要知道N堆干草的中间高度是多少——这就意味着需要对高度进行排序(为了方便,N是奇数,所以中间的高度是独一无二的)。请帮助贝茜确定FJ问题的答案。 PROBLEM NAME: stacking Input Data Line 1: Two space-separated integers, N K. Lines 2..1+K: Each line contains one of FJ's instructions in the form of two space-separated integers A B (1 <= A <= B <= N). Output Data Line 1: The median height of a stack after Bessie completes the instructions.

题目描述

Feeling sorry for all the mischief she has caused around the farm recently,

输入输出格式

输入格式


输出格式


输入输出样例

暂无测试点