Rank List

Time Limit: 10000MS Memory Limit: 65536K

Total Submissions: 9837 Accepted: 3303

Description

Li Ming is a good student. He always asks the teacher about his rank in his class after every exam, which makes the teacher very tired. So the teacher gives him the scores of all the student in his class and asked him to get his rank by himself. However, he has so many classmates, and he can’t know his rank easily. So he tends to you for help, can you help him?

Input

The first line of the input contains an integer N (1 <= N <= 10000), which represents the number of student in Li Ming’s class. Then come N lines. Each line contains a name, which has no more than 30 letters. These names represent all the students in Li Ming’s class and you can assume that the names are different from each other.

In (N+2)-th line, you’ll get an integer M (1 <= M <= 50), which represents the number of exams. The following M parts each represent an exam. Each exam has N lines. In each line, there is a positive integer S, which is no more then 100, and a name P, which must occur in the name list described above. It means that in this exam student P gains S scores. It’s confirmed that all the names in the name list will appear in an exam.

Output

The output contains M lines. In the i-th line, you should give the rank of Li Ming after the i-th exam. The rank is decided by the total scores. If Li Ming has the same score with others, he will always in front of others in the rank list.

Sample Input

3

Li Ming

A

B

2

49 Li Ming

49 A

48 B

80 A

85 B

83 Li Ming

Sample Output

1

2

Source

POJ Monthly,Li Haoyuan

map的简单应用

#include <iostream>
#include <cmath>
#include <map>
#include <cstring>
#include <cstdlib>
#include <stdio.h>
#include <string>
#include <queue>
#include <algorithm> using namespace std; const int INF = 0x3f3f3f3f; const int MAX = 55000; map<string ,int>M; int n,m;
int main()
{
scanf("%d",&n);
int data;
char s[1000];
getchar();
for(int i=0;i<n;i++)
{
gets(s);
M[s]=0;
}
scanf("%d",&m);
map<string ,int>::iterator it;
getchar();
for(int i=0;i<m;i++)
{
for(int i=0;i<n;i++)
{
scanf("%d",&data);
getchar();
gets(s);
M[s]+=data;
}
int ans=1;
for(it=M.begin();it!=M.end();it++)
{
if(it->second>M["Li Ming"])
{
ans++;
}
}
printf("%d\n",ans);
}
return 0;
}

Rank List的更多相关文章

  1. UVA, 10336 Rank the Languages

    难点在于:递归函数和输出: #include <iostream> #include <vector> #include <algorithm> #include ...

  2. [LeetCode] Rank Scores 分数排行

    Write a SQL query to rank scores. If there is a tie between two scores, both should have the same ra ...

  3. rank()函数的使用

    排序: ---rank()over(order by 列名 排序)的结果是不连续的,如果有4个人,其中有3个是并列第1名,那么最后的排序结果结果如:1 1 1 4select scoreid, stu ...

  4. [转]oracle分析函数Rank, Dense_rank, row_number

    oracle分析函数Rank, Dense_rank, row_number 分析函数2(Rank, Dense_rank, row_number)   目录 ==================== ...

  5. 分区函数Partition By的与row_number()的用法以及与排序rank()的用法详解(获取分组(分区)中前几条记录)

    partition by关键字是分析性函数的一部分,它和聚合函数不同的地方在于它能返回一个分组中的多条记录,而聚合函数一般只有一条反映统计值的记录,partition by用于给结果集分组,如果没有指 ...

  6. Learning to rank 介绍

    PS:文章主要转载自CSDN大神hguisu的文章"机器学习排序":          http://blog.csdn.net/hguisu/article/details/79 ...

  7. R语言排序:sort(),rank(),order()示例

    > x<-c(97,93,85,74,32,100,99,67) > sort(x) [1] 32 67 74 85 93 97 99 100 > order(x) [1] 5 ...

  8. [Machine Learning] Learning to rank算法简介

    声明:以下内容根据潘的博客和crackcell's dustbin进行整理,尊重原著,向两位作者致谢! 1 现有的排序模型 排序(Ranking)一直是信息检索的核心研究问题,有大量的成熟的方法,主要 ...

  9. sqlserver 中row_number,rank,dense_rank,ntile排名函数的用法

    1.row_number() 就是行号 2.rank:类似于row_number,不同之处在于,它会对order by 的字段进行处理,如果这个字段值相同,那么,行号保持不变 3.dense_rank ...

  10. sql rank()函数

    RANK() OVER([<partiton_by_clause>]) partition_by_clause 将from子句生成的结果集划分为应用到RANK函数的分区.  Order_b ...

随机推荐

  1. 使用visual studio 2012 编译opencv2.4.9

    最近,由于需要从opencv源码部分对opencv中的某个函数进行修改,以提升算法的速度,因此一直在尝试使用vs2012来编译opencv.期间不乏多次的失败.今天通过实验发现了自己编译的opencv ...

  2. Ruby与Python开发的环境IDE配置(附软件的百度云链接)

    Ruby开发环境配置 1.Aptana_RadRails(提示功能不好,开发Ruby不推荐) 链接:http://pan.baidu.com/s/1i5q96K1 密码:yt04 2.Aptana S ...

  3. Mysql索引介绍及常见索引(主键索引、唯一索引、普通索引、全文索引、组合索引)的区别

    Mysql索引概念:说说Mysql索引,看到一个很少比如:索引就好比一本书的目录,它会让你更快的找到内容,显然目录(索引)并不是越多越好,假如这本书1000页,有500也是目录,它当然效率低,目录是要 ...

  4. geotools

    http://blog.tigerlihao.cn/2010/01/geotools-based-web-map-service.html

  5. 关于.Net Remoting 和 Web Servcie的比较

    参照文献 http://www.cnblogs.com/shinehouse/articles/3001955.html http://www.cnblogs.com/paper/archive/20 ...

  6. 夺命雷公狗---Thinkphp----15之遍历出来的栏目页的完成

    我们首页的写法和我们的文章页的代码很相似,我们要在点击我们的栏目页的时候遍历出对应的代码: 那么我们就直接来创建一个ListsController.class.php的文件,代码如下所示: 老规矩遍历 ...

  7. 夺命雷公狗---微信开发56----微信js-sdk接口开发(3)所有接口功能

    按照上节课程里面的介绍,我们可以先将刚才在signatrue.php里获取到的信息填写进jssdk.htm模版文件里填写各个权限的参数 jssdk.htm代码如下: <!DOCTYPE html ...

  8. ajax讲解:“创建用户”和“用户登录”练习

    ajax可以在不重新加载整个网页的情况下,对网页的某部分进行更新. 传统的网页(不使用 AJAX)如果需要更新内容,必须重载整个网页页面.   接下来,将以例子的形式进行讲解   例一:创建用户   ...

  9. PDO讲解

    PDO的知识点标注在代码里 <?php //造DSN:驱动名:dbname=数据库名:host=服务器地址 $dsn="mysql:dbname=mydb;host=localhost ...

  10. shell 加减乘除

    #!/bin/basha=$1b=$2echo a+b=$(($a+$b))echo a-b=$(($a-$b))echo a*b=$(($a*$b))echo a/b=$(($a/$b))echo ...