UVA-12694 - Meeting Room Arrangement

  • UVa Online Judge 解題結果請於 Submit 後,參閱 uHunt
  • 如果你有任何建議與指教,歡迎於下方留言一起討論喔!
  • 本題選為「20161004 大學程式能力檢定 CPE」題目。

題意概要

學校裡有一間會議室必須事先登記使用使用,由於會議室每天能使用的時間只有 個小時,且有很多登記要使用,所以最佳使用的方式就是:讓使用的會議最多。假設會議室能使用的時間從 個小時)。給你事先登記的每個會議的開始、結束時間,請你寫一個程式算出這天中最多能舉行多少個會議,當然能舉行的會議彼此時間不能有重疊。


Input

The first line is a positive integer () which determines the number of days (test cases). Each test case consists of the time of the candidate events (less than events). Each event time includes integers which are start time(s) and finish time(f), , and . The line containing 0 0 indicates the end of each test case. Note that an event must use at least hour.


Output

For each test case, print out the maximum number of events that can be arranged in the meeting room.


Sample Input

3
0 6
5 7
8 9
5 9
1 2
3 4
0 5
0 0
6 10
5 6
0 3
0 5
3 5
4 5
0 0
1 5
3 9
0 0

Sample Output

4
4
1

Sample Output

0 - Wonderful.
379749833583241 - Wonderful.
3909821048582988049 - Wonderful.
10 - Simple.
profile-image
David Lu
Hello, I'm David Lu. I am a graduate student in Department of Computer Science at National Chiao Tung University, Taiwan. I am in the Networking and Sensing Systems (NSS) Lab at NCTU. If you have any question, please feel free to contact with me.
comments powered by Disqus