问题描述:

源码:

主要要注意输出格式.

#include"iostream"
#include"iomanip"
#include"algorithm"
#include"string"
using namespace std; struct Person
{
string name;
int count;
int score;
}; bool cmp(Person a, Person b)
{
if(a.count > b.count)
{
return true;
}
else if(a.count == b.count)
{
if(a.score < b.score)
{
return true;
}
else if(a.score == b.score)
{
return a.name < b.name;
}
else
{
return false;
}
}
else
{
return false;
}
} int atoi(string str, int start, int end)
{
int result = 0;
for(int i = start; i <= end; i++)
{
result = result * 10 + (str[i] - '0');
}
return result;
} int main()
{
int n, m, index = 0;
string str;
Person *p = new Person[1000];
cin>>n>>m;
while(cin>>p[index].name)
{
p[index].count = 0;
p[index].score = 0;
for(int j = 0; j < n; j++)
{
cin>>str;
if(str[0] != '-' && str[0] != '0')
{
p[index].count++;
if(str[str.length() - 1] == ')')
{
for(int k = 0; k < str.length(); k++)
{
if(str[k] == '(')
{
p[index].score += atoi(str, 0, k - 1);
p[index].score += atoi(str, k+1, str.length() - 2) * m;
break;
}
}
}
else
{
p[index].score += atoi(str, 0, str.length() - 1);
}
}
}
index++;
//if(index == 6)break;
}
sort(p, p + index, cmp);
for(int i = 0; i < index; i++)
{ cout<<std::left<<setw(10)<<p[i].name<<" "<<std::right<<setw(2)<<p[i].count<<" "<<setw(4)<<p[i].score<<endl;
} return 0;
}

  

HD-ACM算法专攻系列(16)——考试排名的更多相关文章

  1. HD-ACM算法专攻系列(23)——Crixalis's Equipment

    题目描述: AC源码:此次考察贪心算法,解题思路:贪心的原则是使留下的空间最大,优先选择Bi与Ai差值最大的,至于为什么?这里用只有2个设备为例,(A1,B1)与(A2,B2),假设先搬运A1,搬运的 ...

  2. HD-ACM算法专攻系列(21)——Wooden Sticks

    题目描述: AC源码: 此题考查贪心算法,解题思路:首先使用快速排序,以w或l按升序排序(注意相等时,应按另一值升序排序),这样就将二维变量比较,变为了一维的,排好序的一边就不需要去管了,只需要对未排 ...

  3. HD-ACM算法专攻系列(22)——Max Sum

    问题描述: AC源码: 此题考察动态规划,解题思路:遍历(但有技巧),在于当前i各之和为负数时,直接选择以第i+1个为开头,在于当前i各之和为正数时,第i个可以不用作为开头(因为前i+1个之和一定大于 ...

  4. HD-ACM算法专攻系列(20)——七夕节

    问题描述: AC源码: /**/ #include"iostream" #include"cmath" using namespace std; int mai ...

  5. HD-ACM算法专攻系列(19)——Leftmost Digit

    问题描述: AC源码: 解题关键是,数据很大,不能强算,需要使用技巧,这里使用科学计算法,令N^N=a*10^n ,取对数后变为 N*log10(N)=log10(a)+n,令x = log10(a) ...

  6. HD-ACM算法专攻系列(18)——Largest prime factor

    题目描述: 源码: 需要注意,若使用cin,cout输入输出,会超时. #include"iostream" #include"memory.h" #defin ...

  7. HD-ACM算法专攻系列(17)——find your present (2)

    题目描述: 源码: #include"iostream" #include"string" using namespace std; bool IsFirstH ...

  8. HD-ACM算法专攻系列(15)——Quoit Design

    问题描述: 源码: 经典问题——最近邻问题,标准解法 #include"iostream" #include"algorithm" #include" ...

  9. HD-ACM算法专攻系列(14)——find your present (2)

    问题描述: 源码: #include"iostream" #include"algorithm" using namespace std; bool cmp(i ...

随机推荐

  1. Android 自定义控件之圆形扩散View(DiffuseView)

    实现效果 使用 属性方法 代码 源码下载 参考链接 实现效果 使用 XML中: <com.airsaid.diffuseview.widget.DiffuseView android:id=&q ...

  2. Android横屏时软键盘全屏问题

    1.使用 SearchView xml加入 android:imeOptions="actionDone|flagNoExtractUi" 可以限制软键盘禁止全屏 <andr ...

  3. 关于出现Failed to instantiate SLF4J LoggerFactory问题原因,解决办法

    在创建spring boot 文档进行配置的时候,因为使用spring boot 父级依赖的版本 <artifactId>spring-boot-starter-parent</ar ...

  4. SQL 字段类型详解

    bit    整型 bit数据类型是整型,其值只能是0.1或空值.这种数据类型用于存储只有两种可能值的数据,如Yes 或No.True 或False .On 或Off.    注意:很省空间的一种数据 ...

  5. [SCOI2008]奖励关_状压动归_数学期望

    Code: #include<cstdio> #include<algorithm> using namespace std; const int maxn = 20; dou ...

  6. Linux-workqueue讲解

    =============  参考  ============= 代码:linux-3.10.65/kernel/workqueue.c =============================== ...

  7. JavaScript对原始数据类型的拆装箱操作

    JS中的基本类型: boolean null undefined string number symbol 每当读取一个基本类型的时候,会隐式的自动进行装箱操作(即:将一个基本类型变成对象): var ...

  8. Codeforces Round #471 (Div. 2)B. Not simply beatiful strings

    Let's call a string adorable if its letters can be realigned in such a way that they form two conseq ...

  9. 2、Ansible配置文件详解

    0.配置文件 两个核心文件:ansible.cfg和hosts文件,默认都存放在/etc/ansible目录下. ansible.cfg:主要设置一些ansible初始化的信息,比如日志存放路径.模块 ...

  10. python第二周:数据类型、列表、字典

    1.模块初识: sys模块: import sys print(sys.path) #path打印环境变量--> ['F:\\python学习\\projects\\s14\\day2', 'F ...