• 题目在这里:1084

  • 题目描述:
    “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!

  • 题意分析:
    有五道题,满分是100分,做出5道就是100,4道90,3道80,2道70,1道60,一道都没做出来就是50分。如果你处于和你做出同样多的题目数的人的前一半,那么就可以多拿5分,做出5道题和0道题的同学不在此列。

  • 我的思路:
    记录时间,按照时间降序排列,但是要按照原来的顺序输出分数,所以需要一个数组来记录原来的顺序,不能在原来的数据上直接进行排序,一开始我没有考虑到这个,吃了WA。还有一个问题,考虑到如果是只有一个人,或者好几个人花同样的时间做出了同样的时间,后者可以按照原来的规则来,一个人就再写一个判断就行。
    虽然看discuss,好像没有这样的数据。w(゚Д゚)w
    最后采用一个二维数组来存储做同样多道题的人数和记录原本的顺序,a[5][105],
    比如a[1][0],就是只做出一道题的人数,假如有5个人,那么a[1][1]–a[1][5]就可以保存他们原来的顺序。

  • 完整代码

#include<iostream>
#include<string.h> using namespace std;
typedef struct student
{
char time[15]; //消耗时间
int score; //分数
}student;
student stu[105];
int main()
{
int i, j, k, n, temp, tt;
int a[5][105]; //用于记录做题人数和做题顺序
while (cin >> n) //学生数目n
{
if (n <= 0) break;
memset(a, 0, sizeof(int) * 5 * 105); //归零
for (i = 1; i <= n; i++)
{
cin >> temp >> stu[i].time; //题目数以及消耗时间
stu[i].score = 50 + temp * 10;
if (temp>0 && temp<5)
{
a[temp][0]++; //做出同样题目数目的人
tt = a[temp][0]; //为了标记顺序
a[temp][tt] = i; //记录做出这道题的人的顺序
}
}
for (i = 1; i<5; i++) //做出题目数目从1到4
{
for (j = 2; j <= a[i][0]; j++)
{
for (k = 2; k <= a[i][0] + 2 - j; k++)
{
if (strcmp(stu[a[i][k - 1]].time, stu[a[i][k]].time) > 0) //按照时间大小降序排列
{
swap(a[i][k - 1], a[i][k]);
}
}
}
for (j = 1; j <= a[i][0] / 2; j++)
stu[a[i][j]].score += 5;
}
for (i = 1; i <= n; i++)
cout << stu[i].score << endl;
cout << endl;
}
return 0;
}

HDU 1084 What Is Your Grade?(排序)的更多相关文章

  1. hdu 1084 What Is Your Grade?

    http://acm.hdu.edu.cn/showproblem.php?pid=1084 What Is Your Grade? Time Limit: 2000/1000 MS (Java/Ot ...

  2. HDU.3342 Legal or Not (拓扑排序 TopSort)

    HDU.3342 Legal or Not (拓扑排序 TopSort) 题意分析 裸的拓扑排序 根据是否成环来判断是否合法 详解请移步 算法学习 拓扑排序(TopSort) 代码总览 #includ ...

  3. HDU.1285 确定比赛名次 (拓扑排序 TopSort)

    HDU.1285 确定比赛名次 (拓扑排序 TopSort) 题意分析 裸的拓扑排序 详解请移步 算法学习 拓扑排序(TopSort) 只不过这道的额外要求是,输出字典序最小的那组解.那么解决方案就是 ...

  4. HDU 1084:What Is Your Grade?

    Problem Description "Point, point, life of student!" This is a ballad(歌谣)well known in col ...

  5. HDU 4857 逃生 (反向拓扑排序 & 容器实现)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4857 逃生 Time Limit: 2000/1000 MS (Java/Others)    Mem ...

  6. ACM: HDU 1285 确定比赛名次 - 拓扑排序

     HDU 1285 确定比赛名次 Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u De ...

  7. ACM: hdu 1811 Rank of Tetris - 拓扑排序-并查集-离线

    hdu 1811 Rank of Tetris Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & % ...

  8. hdu 1285 确定比赛名次 拓扑排序

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1285 有N个比赛队(1<=N<=500),编号依次为1,2,3,....,N进行比赛,比赛 ...

  9. 杭电OJ—— 1084 What Is Your Grade?

    What Is Your Grade? Problem Description “Point, point, life of student!” This is a ballad(歌谣)well kn ...

随机推荐

  1. php函数内不能访问函数外的变量原因

    执行如下代码: $i = 10; function my(){ echo $i; } my(); xdebug显示是:Undefined variable 以前也知道有这个问题存在,即函数内部不可以访 ...

  2. POJ 1861 ——Network——————【最小瓶颈生成树】

    Network Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 15268   Accepted: 5987   Specia ...

  3. PHP运行机制

    PHP运行机制: 访问html文件:访问的域名à解析成IP地址(hosts文件,dns)à找到服务器àapache拿到html文件à返回给浏览器à浏览器解析html内容 访问php文件:apache拿 ...

  4. svg的基本图形与属性【小尾巴的svg学习笔记1】

    因为项目有可能用到, 所以学习了一下,做此笔记,图截自慕课网,侵删. 一.基本图形 1.矩形 x,y定义矩形的左上角坐标: width,height定义矩形的长度和宽度: rx,ry定义矩形的圆角半径 ...

  5. textarea存起来的数据把空格也存起来

    textarea的属性wrap="hard"可以把换行的内容也存起来. <html> <head> <title>这是一个小测试</tit ...

  6. easyui datagrid 动态加载数据 渲染问题,表格错位问题

    $('#dg').datagrid({ url:'datagrid_data.json', columns:[[ {field:'code',title:'Code',width:100}, {fie ...

  7. Win7安装软件,装到microsoft.vc90.crt时卡住的解决办法

    在安装某些程序的时候,可能会出现下列提示:an error occured during the installation of assembly ‘microsoft.vc90.crt,versio ...

  8. 还是要精简开发呀,VS2015太大,VS2010不想装

    公司电脑配置没有很好,所以对于我就是一个挑战. vs2015装上了,但是一打开就卡卡卡,基本没法办公. 公布能用记事本吧,太多不方便: Notepad++做辅助的局部修改还是很好用的,装上插件就智能提 ...

  9. Git-进阶-远程仓库的使用

    一.远程仓库怎么玩 1. 自己搭建一个运行Git的服务器 Git是分布式版本控制系统,同一个Git仓库,可以分布到不同的机器上,但肯定有一台机器有着最原始的版本库,然后别的机器来克隆这个原始版本库,这 ...

  10. Jenkins配置(Jenkins如何与maven项目进行连用)

    一同事,在问关于Jenkins搭建后,他是如何与我们项目进行连用的,如何通过Jenkins去编译我们的项目的,现在介绍下如何通过Jenkins持续编译我们的项目 配置过程 1.确定我们已经搭建好了Je ...