CS240 project Problem 4
该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。
Description
You are asked to hold a conference, the first step of which is to choose the proper dates. The conference must span several consecutive days. Each day, one lecturer is needed to give a presentation, and each lecturer cannot give more than one presentation during the conference. There are lecturers that can participate in the conference in total, the ith of whom is available from day to day , inclusive of and . Several consecutive days can be chosen to hold the conference if there is a way to invite available lecturers to each of the days, without inviting lecturers more than once. For from to , we want to find out how many ways are there to choose consecutive days as the conference dates.
Format
Input
The first line of input contains one integer n, indicating the number of lecturers (). Each of the next n lines contains two integers and , the lecturer is available during these days ().
Output
Print lines, the line contains one integer indicating the number of ways of selecting a conference of days.
Samples
3
1 3
2 4
3 6
6
4
3
Explanation
k = 1: all the days are valid, so there are 6 ways. k = 2: [1, 2], [2, 3], [3, 4], [4, 5] are valid, [5, 6] is not valid, so there are 4 ways. k = 3: [1, 3], [2, 4], [3, 5] are valid, 3 ways.
5
1 3
1 3
1 3
1 3
1 3
3
2
1
0
0
Explanation
k = 1: all the days are valid, so there are 6 ways. k = 2: [1, 2], [2, 3], [3, 4], [4, 5] are valid, [5, 6] is not valid, so there are 4 ways. k = 3: [1, 3], [2, 4], [3, 5] are valid, 3 ways.
Limitation
1s, 256MB for test cases with 10s, 4096MB for the others
CS240 2024 Spring Project Problem
- 状态
- 已结束
- 规则
- IOI
- 题目
- 4
- 开始于
- 2024-5-30 17:00
- 结束于
- 2024-6-24 23:59
- 持续时间
- 607 小时
- 主持人
- 参赛人数
- 99