Rank List
来源:互联网 发布:网络推广计划方案案例 编辑:程序博客网 时间:2024/05/22 10:27
读题注意以下几点:
如果解题数目和所用时间都相等则他们就共同排名在(y+1,y+2,..y+x),y是比他们成绩好的,x是同名次的人数
我的思路先排序,再比较,这个方法很笨拙,先贴上,改天看看大神的
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 teama solvedpa problems with total penalty timeta and teamb solvedpb problems with total penalty timetb. Teama 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, teama gets a higher place than team b in the final results' table if eitherpa > pb, orpa = pb andta < tb.
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 ofx teams that solved the same number of problems with the same penalty time. Let's also say thaty teams performed better than the teams from this group. In this case all teams from the group share placesy + 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 they + x + 1-th place.
Your task is to count what number of teams from the given list shared the k-th place.
The first line contains two integers n andk (1 ≤ k ≤ n ≤ 50). Thenn lines contain the description of the teams: thei-th line contains two integerspi andti (1 ≤ pi, ti ≤ 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.
In the only line print the sought number of teams that got the k-th place in the final results' table.
7 24 104 104 103 202 12 11 10
3
5 43 13 15 33 13 1
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.
这是pony神的程序,第二天才发现我的没过
#include<stdio.h>struct node{int score;int time;}p[1000];int main(){int n,k;int t;struct node q;scanf("%d%d",&n,&k);int i,j;for(i=0;i<n;i++)scanf("%d%d",&p[i].score,&p[i].time);for(i=0;i<n-1;i++){for(j=i+1;j<n;j++){if(p[i].score<p[j].score){q=p[i];p[i]=p[j];p[j]=q;}else if(p[i].score==p[j].score){if(p[i].time>p[j].time){q=p[i];p[i]=p[j];p[j]=q;}}}}int s=0;for(i=0;i<n;i++)if(p[i].score==p[k-1].score&&p[i].time==p[k-1].time)s++;printf("%d\n",s);return 0;}--------------------------------------------------------------------------------
- Rank List
- Rank List
- pku 2153 Rank List
- poj 2153 Rank List
- POJ2153-Rank List
- poj 2153 Rank List
- A. Rank List
- POJ 2153 Rank List
- poj 2153 Rank List
- Poj 2153 Rank List
- poj2153 Rank List
- Rank List CodeForces
- POJ 2135 Rank List
- USTC 1122 Millionaire Rank List
- POJ2153 Rank List(Map)
- Rank List - POJ 2153 map
- USTC 1122:Millionaire Rank List
- POJ 2153 Rank List map
- 【定径圆覆盖最多点模板】
- Activity生命周期
- MyEclipse中自定义jar包库
- Magento学习资源
- 关于上一篇Android编程获取root权限问题的最终解决与分析
- Rank List
- C#事件发布设计模式
- java通过文件头内容判断文件类型
- 基于lame对mp3进行分割的简单实现
- JDK环境变量的配置
- JavaScript basic elements
- android中常见的错误及解决办法
- jetty http client 实现分析
- poj 1845 Sumdiv(分治+快速幂)