F - What Is Your Grade?
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?的更多相关文章
- 动手动脑之小程序:TryAndCatch
源代码 import java.util.InputMismatchException;import java.util.Scanner;public class TryAndCatch {publi ...
- java基础-控制流语句
浏览以下内容前,请点击并阅读 声明 一般情况下,代码的执行按照从上到下的顺序,然而通过加入一些判断,循环和跳转语句,你可以有条件地执行特定的语句. 接下来分三部分介绍Java的控制流语句,他们是判断语 ...
- HDU POJ 1015 Jury Compromise(陪审团的人选,DP)
题意: 在遥远的国家佛罗布尼亚,嫌犯是否有罪,须由陪审团决定.陪审团是由法官从公众中挑选的.先随机挑选n个人作为陪审团的候选人,然后再从这n个人中选m人组成陪审团.选m人的办法是:控方和辩方会根据对候 ...
- 10分钟学会ES7+ES8
撰文为何 身为一个前端开发者,ECMAScript(以下简称ES)早已广泛应用在我们的工作当中.了解ECMA机构流程的人应该知道,标准委员会会在每年的6月份正式发布一次规范的修订,而这次的发布也将作为 ...
- C++课程设计2
PS:大一下学期C++课程设计 1.成绩管理系统 #include<stdio.h> #include<string> #include<iostream> #in ...
- Python的控制语句
1. 控制语句 控制语句是用来改变程序执行的顺序.程序利用控制语句有条件地执行语句,循环地执行语句或者跳转到程序中的其他部分执行语句. Python支持三种不同的控制语句:if,for和while, ...
- [shell] if语句用法
bash中如何实现条件判断?条件测试类型: 整数测试 字符测试 文件测试 一.条件测试的表达式: [ expression ] 括号两端必须要有空格 [[ expres ...
- if 语句中的判断
经常写shell的朋友可能已经很熟了.有不同意见的同学请指出来,在这里多谢大家了. bash中如何实现条件判断?条件测试类型: 整数测试 字符测试 文件测试 一.条件测试的表达式: ...
- es7,es8
ES7新特性 ES7在ES6的基础上添加了三项内容:求幂运算符(**).Array.prototype.includes()方法.函数作用域中严格模式的变更. Array.prototype.incl ...
随机推荐
- springboot整合dubbo+zookeeper最新详细
引入 最近和小伙伴做一个比赛,处于开发阶段,因为涉及的服务比较多,且服务需要分开部署在不同的服务器上,讨论之后,打算采用分布式来做,之前学习springboot的时候,部分章节涉及到了springbo ...
- Layui+Servlet+MyBatis+Mysql实现的大学生创新竞赛管理平台
项目简介 项目来源于:https://gitee.com/fly-liuhao/SCMS 原仓库中未上传jar包及登录异常,现将修改过的源码上传到百度网盘上. 链接:https://pan.baidu ...
- vim-0-indent(缩进)
缩进: 参考自http://liuzhijun.iteye.com/blog/1831548,http://blog.csdn.net/chenxiang6891/article/details/41 ...
- 10行Python代码计算汽车数量
当你还是个孩子坐车旅行的时候,你玩过数经过的汽车的数目的游戏吗? 在这篇文章中,我将教你如何使用10行Python代码构建自己的汽车计数程序. 以下是环境及相应的版本库: Python版本 3.6.9 ...
- 磐创AI GPU租用平台上线,1小时不到1块钱
>> 小白也能看懂的PyTorch从入门到精通系列 << 今天磐创AI GPU租赁平台上线了!!!为大家解决用GPU难的问题!一块10G显存的GPU,1小时租用费用不到1块钱, ...
- React入门(2)
承接上次学习的react,今天继续学习react 划重点!!! 今天学习的全是react的核心概念:①props②ref③state 一.核心概念---props 作用:主要用来实现父子组件通信 1. ...
- 3.介绍ASP.NET Core框架
介绍ASP.NET Core框架 在这篇文章中,我将要向你们简短介绍一下ASP.NET Core 框架.当今社会,当提到软件开发,每个人都是讨论着开源以及跨平台开发.总所周知,微软是以它的基于Wind ...
- [noip模拟]小猫爬山<迭代深搜>
[题目描述]: Freda和rainbow饲养了N只小猫,这天,小猫们要去爬山.经历了千辛万苦,小猫们终于爬上了山顶,但是疲倦的它们再也不想徒步走下山了(呜咕>_<). Freda和rai ...
- Unity引擎入门——制作第一个2D游戏(2)角色移动与动画
在上一节的内容里,我们已经创建出了一个主角,也搭建了一个简单的场景. 传送门:https://www.cnblogs.com/zny0222/p/12653088.html 既然有了主角,要怎样才能让 ...
- 树莓派中Docker部署.Net Core 3.1 (一)
一.背景 受疫情影响,已经在家强制事假一个月了,除了刷简历外就是在家学习,闲来无事,最近买了几个树莓派4B的板子回来,准备用树莓派搭建个自动部署的平台和微服务示例,长话短说,节约时间,直接进入正题吧 ...