# BZOJ 1150: [CTSC2007]数据备份Backup（堆维护带有反悔性质的贪心）

Description
你在一家 IT 公司为大型写字楼或办公楼（offices）的计算机数据做备份。然而数据备份的工作是枯燥乏味

上例中最好的配对方案是将第 1 个和第 2 个办公楼相连，第 3 个和第 4 个办公楼相连。这样可按要求使用
K=2 条电缆。第 1 条电缆的长度是 3km-1km=2km ，第 2 条电缆的长度是 6km-4km=2km。这种配对方案需要总长
4km 的网络电缆，满足距离之和最小的要求。
Input
输入的第一行包含整数n和k，其中n（2 ≤ n ≤100 000）表示办公楼的数目，k（1≤ k≤ n/2）表示可利用

Output
输出应由一个正整数组成，给出将2K个相异的办公楼连成k对所需的网络电缆的最小总长度。

Sample Input
5 2

1

3

4

6

12
Sample Output
4

# BZOJ 1800: [Ahoi2009]fly 飞行棋（双指针找直径）

Description

Input

Output

Sample Input
8

1

2

2

3

1

1

3

3

Sample Output
3

HINT
N<= 20 题图没粘下来还是去bzoj看吧。。。 暴力的方法不说了，但是我们发现一个问题：如果在圆上找对边相等的四个点就可以判断出来是否是矩形。因为这些都是中心对称的图形啊QAQ。。。 所以这样我们可以证明只要有两条对角线，他们就可以组成一个矩形，所以数直径就好啦QAQ。。。

# hdu 6252 Subway Chasing（差分约束系统）

Problem Description
Mr. Panda and God Sheep are roommates and working in the same company. They always take subway to work together. There are N subway stations on their route, numbered from 1 to N. Station 1 is their home and station N is the company.
One day, Mr. Panda was getting up later. When he came to the station, God Sheep has departed X minutes ago. Mr. Panda was very hurried, so he started to chat with God Sheep to communicate their positions. The content is when Mr. Panda is between station A and B, God Sheep is just between station C and D.
B is equal to A+1 which means Mr. Panda is between station A and A+1 exclusive, or B is equal to A which means Mr. Panda is exactly on station A. Vice versa for C and D. What’s more, the communication can only be made no earlier than Mr. Panda departed and no later than God Sheep arrived.
After arriving at the company, Mr. Panda want to know how many minutes between each adjacent subway stations. Please note that the stop time at each station was ignored.

Input
The first line of the input gives the number of test cases, T. T test cases follow.
Each test case starts with a line consists of 3 integers N, M and X, indicating the number of stations, the number of chat contents and the minute interval between Mr. Panda and God Sheep. Then M lines follow, each consists of 4 integers A, B, C, D, indicating each chat content.
1≤T≤30
1≤N,M≤2000
1≤X≤109
1≤A,B,C,D≤N
A≤B≤A+1
C≤D≤C+1

Output
For each test case, output one line containing “Case #x: y”, where x is the test case number (starting from 1) and y is the minutes between stations in format t1,t2,…,tN−1. ti represents the minutes between station i and i+1. If there are multiple solutions, output a solution that meets 0=tc
ta+x<=td 否则 tb+x>tc
ta+x