CF1305H.Kuroni the Private Tutor
NOI/NOI+/CTSC
通过率:0%
时间限制:3.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
As a professional private tutor, Kuroni has to gather statistics of an exam. Kuroni has appointed you to complete this important task. You must not disappoint him.
The exam consists of n questions, and m students have taken the exam. Each question was worth 1 point. Question i was solved by at least li and at most ri students. Additionally, you know that the total score of all students is t.
Furthermore, you took a glance at the final ranklist of the quiz. The students were ranked from 1 to m, where rank 1 has the highest score and rank m has the lowest score. Ties were broken arbitrarily.
You know that the student at rank pi had a score of si for 1≤i≤q.
You wonder if there could have been a huge tie for first place. Help Kuroni determine the maximum number of students who could have gotten as many points as the student with rank 1, and the maximum possible score for rank 1 achieving this maximum number of students.
作为一名专业的私人辅导老师,库罗尼需要汇总一次考试的统计数据。库罗尼已委派你完成这项重要任务,你绝不能让他失望。
本次考试共有 n 道题目,m 名学生参加了考试。每道题目的分值均为 1 分。第 i 题至少被 li 名学生、至多被 ri 名学生答对。此外,你还知道所有学生的总得分之和为 t。
另外,你匆匆浏览了本次测验的最终排名表。学生按得分从高到低排序,依次编号为 1 至 m,其中排名 1 的学生得分最高,排名 m 的学生得分最低;若出现并列,则任意打破平局。
你已知:对于 1≤i≤q,排名为 pi 的学生得分为 si。
你不禁好奇:是否可能有大量学生并列第一?请帮助库罗尼确定:最多可能有多少名学生与排名第 1 的学生得分相同,以及在达到该最多人数的前提下,排名第 1 的学生所能取得的最高得分是多少。
输入格式
The first line of input contains two integers (1≤n,m≤105), denoting the number of questions of the exam and the number of students respectively.
The next n lines contain two integers each, with the i-th line containing li and ri (0≤li≤ri≤m).
The next line contains a single integer q (0≤q≤m).
The next q lines contain two integers each, denoting pi and si (1≤pi≤m, 0≤si≤n). It is guaranteed that all pi are distinct and if pi≤pj, then si≥sj.
The last line contains a single integer t (0≤t≤nm), denoting the total score of all students.
输入的第一行包含两个整数(1≤n,m≤105),分别表示考试的题目数量和学生人数。
接下来的 n 行每行包含两个整数,其中第 i 行包含 li 和 ri(0≤li≤ri≤m)。
下一行包含一个整数 q(0≤q≤m)。
接下来的 q 行每行包含两个整数,表示 pi 和 si(1≤pi≤m,0≤si≤n)。保证所有 pi 互不相同,且若 pi≤pj,则有 si≥sj。
最后一行包含一个整数 t(0≤t≤nm),表示所有学生的总分。
输出格式
Output two integers: the maximum number of students who could have gotten as many points as the student with rank 1, and the maximum possible score for rank 1 achieving this maximum number of students. If there is no valid arrangement that fits the given data, output −1 −1.
输出两个整数:可能获得与排名第 1 的学生相同分数的学生的最大人数,以及在达到该最大人数的前提下,排名第 1 的学生所能取得的最高分数。如果不存在符合给定数据的有效安排,则输出 −1 −1。
输入输出样例
输入#1
5 4 2 4 2 3 1 1 0 1 0 0 1 4 1 7
输出#1
3 2
输入#2
5 6 0 6 0 6 2 5 6 6 4 6 1 3 3 30
输出#2
-1 -1
说明/提示
For the first sample, here is one possible arrangement that fits the data:
Students 1 and 2 both solved problems 1 and 2.
Student 3 solved problems 2 and 3.
Student 4 solved problem 4.
The total score of all students is T=7. Note that the scores of the students are 2, 2, 2 and 1 respectively, which satisfies the condition that the student at rank 4 gets exactly 1 point. Finally, 3 students tied for first with a maximum score of 2, and it can be proven that we cannot do better with any other arrangement.
对于第一个样例,以下是一种符合数据的可能安排:
学生 1 和 2 均解出了题目 1 和 2。
学生 3 解出了题目 2 和 3。
学生 4 解出了题目 4。
所有学生的总分为 T=7。注意,各位学生的得分分别为 2、2、2 和 1,满足“排名第 4 的学生恰好得 1 分”的条件。最终,有 3 名学生并列第一,最高得分为 2;可以证明,任何其他安排均无法得到更优的结果。
输入解题思路,AI测评打分。不知道怎么写?