P2877 [USACO07JAN]牛校Cow School

    • 41通过
    • 93提交
  • 题目提供者 FarmerJohn2
  • 评测方式 云端评测
  • 标签 贪心 USACO 2007
  • 难度 省选/NOI-
  • 时空限制 1000ms / 128MB

题解

  • 提示:收藏到任务计划后,可在首页查看。
  • 体验新版界面

    最新讨论 显示

    推荐的相关题目 显示

    题目描述

    Bessy is going to school and doing well. She has taken N (1 ≤ N ≤ 5000 -- except one case where 1 ≤ N ≤ 50,000) tests and recorded the scores (Ti points out of Pi points for test i; 0 ≤ Ti ≤ Pi < 40,000; 0 < Pi) as this task's input.

    Her teacher will drop the D tests with the lowest percentage (Ti⁄Pi) before calculating Bessie's final grade (which is the sum of the remaining test score points over the sum of the remaining total test points). Bessy is good at math and quickly realizes that this does not benefit her as much as it might.

    To prove her point, Bessy wants to find all values of D for which she could have ended up with a higher grade by choosing to drop different tests than the teacher would have. Help her by finding and printing all values of D for which this is possible.

    Bessy has noted that, amazingly, she has never scored the same percentage on two different tests.

    一个人参加了N场考试,第i场满分为P[i],其得分为T[i]。现在要删去其中D次考试的成绩,用剩下的总得分除以剩下的满分之和,作为其最终成绩。问对于哪些D而言,删除得分比(即T[i]/P[i])最小的D场得到的最终成绩不是最优的(用其他方法可以得到更高的最终成绩)。

    输入输出格式

    输入格式:

    Line 1: A single integer, N

    Lines 2..N+1: Line i+1 contains two space-separated integers: Ti and Pi

    输出格式:

    Line 1: A single integer K (0 ≤ K ≤ N) that is the number of values of D for which Bessy could have ended up with a higher grade by dropping a different set of D tests than the teacher.

    Lines 2..K+1: The values of D for which this is true, in ascending numerical order.

    输入输出样例

    输入样例#1: 复制
    5
    1 2
    5 9
    3 8
    4 10
    1 3
    输出样例#1: 复制
    2
    1
    2
    提示
    标程仅供做题后或实在无思路时参考。
    请自觉、自律地使用该功能并请对自己的学习负责。
    如果发现恶意抄袭标程,将按照I类违反进行处理。