Rank List

原创 2012年03月24日 01:39:18
    这是我第二次做codeforces的比赛,成绩没第一次好,主要原因还是那个万年不变的原因——看不懂题意。报告一下时间2012年3、24 1:12。先不唠叨,很有必要感谢我的上铺兄弟zhifa,他的英语水平很ok,就让他帮我看题,我太心急了,在没有了解题意的情况下就敲代码,结果呢?结果悲剧了!就又一次读题,终于明白了题意,再次感谢他!(童鞋们,还是学英语吧!谁让祖国不强大,啥时比赛都有中英对照时,哈哈。又幻想了.....)
       读题注意以下几点:
      如果解题数目和所用时间都相等则他们就共同排名在(y+1,y+2,..y+x),y是比他们成绩好的,x是同名次的人数
       我的思路先排序,再比较,这个方法很笨拙,先贴上,改天看看大神的
A. Rank List
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

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.

<P< p><P< p>
Input
<P< p>

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.

<P< p><P< p>
Output
<P< p>

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

<P< p><P< p>
Sample test(s)
<P< p><P< p>
Input
7 2
4 10
4 10
4 10
3 20
2 1
2 1
1 10
Output
3
Input
5 4
3 1
3 1
5 3
3 1
3 1
Output
4
<P< p><P< p>
Note
<P< p>

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;
}
--------------------------------------------------------------------------------



版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

HDU5131 Song Jiang's rank list(模拟)

题目: Song Jiang's rank list Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 512000/512000...

POJ 2153 Rank List map

Description Li Ming is a good student. He always asks the teacher about his rank in his class after...
  • wr132
  • wr132
  • 2015-01-27 16:37
  • 415

HDU 5131 Song Jiang's rank list(水题)

题目大意: 按杀人数降序输出水浒英雄,若杀人数相同,按姓名字母序升序输出。并统计输出两种名次。 解题思路: 排序后,顺序扫描统计即可。水题。

Poj 2153 Rank List

Rank List Time Limit: 10000MS   Memory Limit: 65536K Total Submissions: 10206   Ac...

UVALive Problem 7073 Song Jiang's rank list(排序)——2014ACM/ICPC亚洲区广州站

UVALive Problem 7073 Song Jiang's rank list(排序)——2014ACM/ICPC亚洲区广州站

Song Jiang's rank list

Song Jiang's rank list Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 512000/512000 K (Java...

HDU 5131 Song Jiang's rank list (14广州 排序 水题)

Song Jiang's rank list Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 512000/512000 K (Jav...

USTC 1122:Millionaire Rank List

传送门: Millionaire Rank List Time Limit: 1000ms Memory Limit: 131072kb Description In the wild un...

POJ2153 - Rank List - map模拟

1.题目描述: Li Ming is a good student. He always asks the teacher about his rank in his class after...

HDU 5131 Song Jiang's rank list (结构体+MAP,2014广州现场赛)

题目链接:HDU 5131 Song Jiang's rank list 题意:对给出的好汉按杀敌数从大到小排序,若相等,按字典序排。M个询问,询问名字输出对应的主排名和次排名。(排序之后)主排名是...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)