# DCP-413: Sanvi and Exam Marks Back to All Problems

Medium Beginners Problems > Ad-hoc

Sanvi is a teacher. She lost exam answer sheets of students. So, she is planning to provide same marks to every student. For each student, she knows in advance the lower bound and upper bound of marks that make them happy. Now, she asks your help to count the total number of different marks that make at least **P** students happy. Input: ------ Input starts with an integer **T (1<=T<=20)**, denoting the number of test cases. Each case starts with two space separated integers **N (1 ≤ N ≤ 10000)** denoting the number of students and . **P (1 ≤ P ≤ N )** .The next N lines will contain two space separated integers **( Li and Ri, Li<=Ri , Li>=1 and Ri<=100000 )** denoting lowerbound and upper bound of marks that make ith student happy. Output: ------- For each case of input, output the total number of different marks that make at least **P** student happy. Sample Input ------------ 1 3 2 1 10 8 12 12 15 Sample Output ------------- 4 Explanation:<br> For the given sample, If Sanvi provide marks either of 8,9,10 or 12, at least 2 student will be happy.

### Problem Limits

 Language Time Limit (seconds) C 1.00 C++ 1.00 C++14 1.00 C# 2.00 Go 2.00 Java 2.00 JavaScript 2.00 Objective-C 2.00 Perl 2.00 PHP 2.00 Python 2.00 Python3 2.00 Ruby 2.00 VB.Net 2.00

# 27/38

Solve/Submission

### Ranking

# User Language Timing
01 FariD Cpp 0.02s
02 mahade31 Cpp14 0.05s
03 SakibAlamin Cpp 0.05s
04 DynamicOvi Cpp 0.05s
05 Anubis Cpp 0.05s
06 ssavi Cpp 0.05s
07 emrul Cpp 0.05s
08 tariqiitju Cpp 0.05s
09 Mr_adnan Cpp 0.05s
10 Pure_Protea Cpp14 0.06s
11 _GhOstMan_ Cpp 0.06s
12 wayne6172 C 0.06s
13 mepromee Cpp 0.06s
14 rayhan50001 Cpp 0.07s
15 skmonir Cpp 0.07s
16 feodorv C 0.11s
17 kissu_pari_na Cpp14 0.11s
18 Silent_Warrior Cpp 0.13s
19 mhiceiu Cpp 0.14s
20 anik_JU Cpp 0.62s
Feedback