“Point, point, life of student!” 
This is a ballad(歌谣)well known in colleges, and you must care about your score in this exam too. How many points can you get? Now, I told you the rules which are used in this course. 
There are 5 problems in this final exam. And I will give you 100 points if you can solve all 5 problems; of course, it is fairly difficulty for many of you. If you can solve 4 problems, you can also get a high score 95 or 90 (you can get the former(前者) only when your rank is in the first half of all students who solve 4 problems). Analogically(以此类推), you can get 85、80、75、70、65、60. But you will not pass this exam if you solve nothing problem, and I will mark your score with 50. 
Note, only 1 student will get the score 95 when 3 students have solved 4 problems. 
I wish you all can pass the exam! 
Come on! 

InputInput contains multiple test cases. Each test case contains an integer N (1<=N<=100, the number of students) in a line first, and then N lines follow. Each line contains P (0<=P<=5 number of problems that have been solved) and T(consumed time). You can assume that all data are different when 0<p. 
A test case starting with a negative integer terminates the input and this test case should not to be processed. 
OutputOutput the scores of N students in N lines for each case, and there is a blank line after each case. 
Sample Input

4
5 06:30:17
4 07:31:27
4 08:12:12
4 05:23:13
1
5 06:30:17
-1

Sample Output

100
90
90
95 100

刚看到这个题目的时候有点懵,但是尝试着写了一下。。。。思路简单的很

#include<iostream>
#include<algorithm>
#include<string>
#include<cstdio>
#include<math.h>
using namespace std;
struct stu
{
int a;
string b;
int c;//记录当前的分数
};
//先用sort对副本数组num2排序,a优先,b其次,c不用管 ,最后在转换为num1
bool cmp(stu x,stu y)
{
if(x.a!=y.a)
return x.a>y.a;
return x.b<y.b;//时间取较小的
}
int main()
{
int n;
while(cin>>n)
{
int s[]={};//,一定要定义在循环内部,,,错了好几次
struct stu num1[],num2[];
if(n<)
break; for(int i=;i<n;i++)
{
cin>>num1[i].a>>num1[i].b;
num2[i].a=num1[i].a;
num2[i].b=num1[i].b;
s[num1[i].a]++;//记录每个值出现的次数
} sort(num2,num2+n,cmp);
int x=,y=,z=,w=;
for(int i=;i<n;i++)
{
if(num2[i].a==)
{
num2[i].c=;
} else if(num2[i].a==)
{
x++;//记录4出现的次数
if(s[]==)
num2[i].c=;
else
{
if(s[]/>=x)//如果4出现的次数比中值小 则赋值为95,否则 90
{
num2[i].c=;
}
else
{
num2[i].c=;
}
}
}
else if(num2[i].a==)
{
y++;
if(s[]==)
num2[i].c=;
else
{
if(s[]/>=y)
{
num2[i].c=;
}
else
{
num2[i].c=;
}
}
}
else if(num2[i].a==)
{
z++;
if(s[]==)
num2[i].c=;
else
{
if(s[]/>=z)
{
num2[i].c=;
}
else
{
num2[i].c=;
}
}
} else if(num2[i].a==)
{
w++;
if(s[]==)
num2[i].c=;
else
{
if(s[]/>=w)
{
num2[i].c=;
}
else
{
num2[i].c=;
}
}
}
else if(num2[i].a==)
{
num2[i].c=;
}
}
//转换 根据num2 对num1 中的c赋值
for(int i=;i<n;i++)
{
for(int j=;j<n;j++)
{
if(num1[i].a==num2[j].a && num1[i].b==num2[j].b)
{
num1[i].c=num2[j].c;
break;
}
}
}
for(int i=;i<n;i++)
cout<<num1[i].c<<endl;
cout<<endl;
}
return ;
}
//自己造的数据
/*
15
5 06:30:17
4 07:31:27
4 08:12:12
4 05:23:13
4 06:30:17
3 05:23:13
3 05:23:12
3 05:23:11
3 05:23:10
3 05:23:09
2 06:30:17
2 06:30:12
1 05:23:01
0 08:12:12
*/

F - What Is Your Grade?的更多相关文章

  1. 动手动脑之小程序:TryAndCatch

    源代码 import java.util.InputMismatchException;import java.util.Scanner;public class TryAndCatch {publi ...

  2. java基础-控制流语句

    浏览以下内容前,请点击并阅读 声明 一般情况下,代码的执行按照从上到下的顺序,然而通过加入一些判断,循环和跳转语句,你可以有条件地执行特定的语句. 接下来分三部分介绍Java的控制流语句,他们是判断语 ...

  3. HDU POJ 1015 Jury Compromise(陪审团的人选,DP)

    题意: 在遥远的国家佛罗布尼亚,嫌犯是否有罪,须由陪审团决定.陪审团是由法官从公众中挑选的.先随机挑选n个人作为陪审团的候选人,然后再从这n个人中选m人组成陪审团.选m人的办法是:控方和辩方会根据对候 ...

  4. 10分钟学会ES7+ES8

    撰文为何 身为一个前端开发者,ECMAScript(以下简称ES)早已广泛应用在我们的工作当中.了解ECMA机构流程的人应该知道,标准委员会会在每年的6月份正式发布一次规范的修订,而这次的发布也将作为 ...

  5. C++课程设计2

    PS:大一下学期C++课程设计 1.成绩管理系统 #include<stdio.h> #include<string> #include<iostream> #in ...

  6. Python的控制语句

    1.  控制语句 控制语句是用来改变程序执行的顺序.程序利用控制语句有条件地执行语句,循环地执行语句或者跳转到程序中的其他部分执行语句. Python支持三种不同的控制语句:if,for和while, ...

  7. [shell] if语句用法

    bash中如何实现条件判断?条件测试类型:    整数测试    字符测试    文件测试 一.条件测试的表达式:    [ expression ]  括号两端必须要有空格    [[ expres ...

  8. if 语句中的判断

    经常写shell的朋友可能已经很熟了.有不同意见的同学请指出来,在这里多谢大家了. bash中如何实现条件判断?条件测试类型:    整数测试    字符测试    文件测试 一.条件测试的表达式: ...

  9. es7,es8

    ES7新特性 ES7在ES6的基础上添加了三项内容:求幂运算符(**).Array.prototype.includes()方法.函数作用域中严格模式的变更. Array.prototype.incl ...

随机推荐

  1. css第二波

    目录 css第二波 盒子模型 浮动 三种取值 清除浮动 浮动页面布局 溢出 定位 相对定位 relative(相对定位) 绝对定位 absolute(绝对定位) 固定定位 fixed(固定) 模糊框 ...

  2. 3.Scikit-Learn实现完整的机器学习项目

    1       完整的机器学习项目 完成项目的步骤: (1)    项目概述 (2)    获取数据 (3)    发现并可视化数据,发现规律. (4)    为机器学习算法准备数据. (5)    ...

  3. MySQL5.7 import表结构报错超出表空间界限

    事后测试了一下,一下方法就是垃圾,看看可以,别跟着学!!! 数据库重启后,问题依然暴露出来了,参数什么的都是扯,擦 记录一个困扰我好几天的问题.先贴上报错: space name jxtms/Cost ...

  4. 万字综述,核心开发者全面解读PyTorch内部机制

    斯坦福大学博士生与 Facebook 人工智能研究所研究工程师 Edward Z. Yang 是 PyTorch 开源项目的核心开发者之一.他在 5 月 14 日的 PyTorch 纽约聚会上做了一个 ...

  5. Matlab 编程简介与实例

    函数作图 二维平面曲线作图函数  plot(x, y, 's') x, y是长度相同的向量,s表示线型和颜色 如果作多条曲线在同一图上,则用函数: plot(x1, y1, 's1', x2, y2, ...

  6. 一文教会你如何在 Spring 中进行集成测试,太赞了

    不得不说,测试真的是太重要了!但并不是所有的开发者都这样认为,这种感觉在我回到洛阳后尤其强烈.竟然有团队成员不经测试就把代码提交到代码库,并且是会报错的那种,我天呐,遇到这种队友我也是醉了. 我之前是 ...

  7. 小白快速使用fetch与后端交互

    本人专心后端,但在完成页面碰到了交互,选择了fetch来完成, 总结了一下简单的使用fetch的方法. fetch是纯原生JS与后端交互的方法,请注意,Fetch规格不同于jQuery.ajax(), ...

  8. PTA数据结构与算法题目集(中文) 7-3

    PTA数据结构与算法题目集(中文)  7-3 树的同构 给定两棵树T1和T2.如果T1可以通过若干次左右孩子互换就变成T2,则我们称两棵树是“同构”的.例如图1给出的两棵树就是同构的,因为我们把其中一 ...

  9. 手动搭建I/O网络通信框架1:Socket和ServerSocket入门实战,实现单聊

    资料:慕课网 第二章:手动搭建I/O网络通信框架2:Socket和ServerSocket入门实战,实现单聊 这个基础项目会作为BIO.NIO.AIO的一个前提,后面会有数篇博客会基于这个小项目利用B ...

  10. CentOS 6.5系统实现NFS文件共享

    一台Linux server ip 192.168.1.254,一台Linux client ip 192.168.1.100操作系统:CentOS 6.5需求描述:1:将/root 共享给192.1 ...