CF166A.Rank List

普及-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Another programming contest is over. You got hold of the contest's final results table. The table has the following data. For each team we are shown two numbers: the number of problems and the total penalty time. However, for no team we are shown its final place.

You know the rules of comparing the results of two given teams very well. Let's say that team a solved p__a problems with total penalty time t__a and team b solved p__b problems with total penalty time t__b. Team a gets a higher place than team b in the end, if it either solved more problems on the contest, or solved the same number of problems but in less total time. In other words, team a gets a higher place than team b in the final results' table if either p__a > p__b, or p__a = p__b and t__a < t__b.

It is considered that the teams that solve the same number of problems with the same penalty time share all corresponding places. More formally, let's say there is a group of x teams that solved the same number of problems with the same penalty time. Let's also say that y teams performed better than the teams from this group. In this case all teams from the group share places y + 1, y + 2, ..., y + x. The teams that performed worse than the teams from this group, get their places in the results table starting from the y + x + 1-th place.

Your task is to count what number of teams from the given list shared the k-th place.

又一场编程竞赛结束了。你拿到了本次竞赛的最终成绩表。该表格包含以下数据:对于每支队伍,显示两个数字——解出的问题数量和总罚时。然而,没有任何一支队伍显示其最终名次。

你非常熟悉比较两支队伍成绩的规则。假设队伍 aa 解出了 pap_a 道题,总罚时为 tat_a;队伍 bb 解出了 pbp_b 道题,总罚时为 tbt_b。那么,在最终成绩表中,队伍 aa 的名次高于队伍 bb,当且仅当它解出的问题数更多,或者解出的问题数相同但总罚时更少。换言之,队伍 aa 在最终成绩表中名次高于队伍 bb,当且仅当 pa>pbp_a > p_b,或 pa=pbp_a = p_b 且 ta<tbt_a < t_b。

若若干支队伍解出的问题数与罚时均完全相同,则它们共享所有对应的名次。更严格地说,假设有 xx 支队伍解出的问题数与罚时均相同,另有 yy 支队伍的成绩优于该组所有队伍。此时,该组所有队伍共同占据第 y+1y+1、y+2y+2、…、y+xy+x 名。而成绩劣于该组所有队伍的那些队伍,则从第 y+x+1y+x+1 名开始依次获得后续名次。

你的任务是:计算在给定的队伍列表中,有多少支队伍共同占据了第 kk 名。

输入格式

The first line contains two integers n and k (1 ≤ k ≤ n ≤ 50). Then n lines contain the description of the teams: the i-th line contains two integers p__i and t__i (1 ≤ p__i, t__i ≤ 50) — the number of solved problems and the total penalty time of the i-th team, correspondingly. All numbers in the lines are separated by spaces.

第一行包含两个整数 nn 和 kk(1≤k≤n≤501 \leq k \leq n \leq 50)。接下来的 nn 行描述各支队伍:第 ii 行包含两个整数 pip_i 和 tit_i(1≤pi,ti≤501 \leq p_i, t_i \leq 50),分别表示第 ii 支队伍解出的问题数量和总罚时。每行中的所有数字均以空格分隔。

输出格式

In the only line print the sought number of teams that got the k-th place in the final results' table.

在唯一的一行中输出最终成绩表中获得第 kk 名的队伍数量。

输入输出样例

  • 输入#1

    7 2
    4 10
    4 10
    4 10
    3 20
    2 1
    2 1
    1 10

    输出#1

    3
  • 输入#2

    5 4
    3 1
    3 1
    5 3
    3 1
    3 1

    输出#2

    4

说明/提示

The final results' table for the first sample is:

  • 1-3 places — 4 solved problems, the penalty time equals 10
  • 4 place — 3 solved problems, the penalty time equals 20
  • 5-6 places — 2 solved problems, the penalty time equals 1
  • 7 place — 1 solved problem, the penalty time equals 10

The table shows that the second place is shared by the teams that solved 4 problems with penalty time 10. There are 3 such teams.

The final table for the second sample is:

  • 1 place — 5 solved problems, the penalty time equals 3
  • 2-5 places — 3 solved problems, the penalty time equals 1

The table shows that the fourth place is shared by the teams that solved 3 problems with penalty time 1. There are 4 such teams.

第一个样例的最终排名表如下:

  • 第 1–3 名:解出 4 道题,罚时为 10
  • 第 4 名:解出 3 道题,罚时为 20
  • 第 5–6 名:解出 2 道题,罚时为 1
  • 第 7 名:解出 1 道题,罚时为 10

该表表明,第 2 名由解出 4 道题且罚时为 10 的队伍共享,共有 3 支这样的队伍。

第二个样例的最终排名表如下:

  • 第 1 名:解出 5 道题,罚时为 3
  • 第 2–5 名:解出 3 道题,罚时为 1

该表表明,第 4 名由解出 3 道题且罚时为 1 的队伍共享,共有 4 支这样的队伍。

输入解题思路,AI测评打分。不知道怎么写?

首页