杭电OJ—— 1084 What Is Your Grade?
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!
A test case starting with a negative integer terminates the input and this test case should not to be processed.
5 06:30:17
4 07:31:27
4 08:12:12
4 05:23:13
1
5 06:30:17
-1
90
90
95
100
#include <iostream>
#include <algorithm>
using namespace std;
const int SIZE = 101; typedef struct /*结构体,用于存储输入的数据*/
{
int solved; /*解决问题的数目*/
int located; /*学生的位置*/
int h, m, s; /*所花费的时间*/
int soc; /*最终的成绩*/
}time; bool cmp(time &bi1, time &bi2) /*比较函数,用于排序*/
{
if (bi1.h > bi2.h) return false;
else if (bi1.h < bi2.h) return true;
else
{
if (bi1.m > bi2.m) return false;
else if (bi1.m < bi2.m) return true;
else
{
if (bi1.s > bi2.s) return false;
else if (bi1.s < bi2.s) return true;
}
}
} int main()
{
int num;
time stu[SIZE];
time sortArr[4][SIZE];
int p, q , r, k, i;
while((cin >> num) && (num >= 0))
{
p = q = r = k = 0;
for (i = 0; i < num; i++)
{
cin >> stu[i].solved;
scanf ("%d:%d:%d", &stu[i].h, &stu[i].m, &stu[i].s);
stu[i].located = i; /*记录下输入时的位置*/ /*下面的思路就是:分数能处理的就处理,如解决了5道题(100)和0道题(50)
不能处理的话,我们先将该数分类存入一个数组,之后再做处理
*/
if (stu[i].solved == 5)
{
stu[i].soc = 100;
}
if (stu[i].solved == 4)
{
sortArr[0][p] = stu[i];
p++;
}
if (stu[i].solved == 3)
{
sortArr[1][q] = stu[i];
q++;
}
if (stu[i].solved == 2)
{
sortArr[2][r] = stu[i];
r++;
}
if (stu[i].solved == 1)
{
sortArr[3][k] = stu[i];
k++;
}
if (stu[i].solved == 0)
{
stu[i].soc = 50;
}
} if (p >= 1)
{
sort (sortArr[0], sortArr[0] + p, cmp); /*先排序,按照耗时从小到大排序*/
for (i = 0; i < p / 2; i++) /*前半部分得高分*/
{
stu[sortArr[0][i].located].soc = 95;
}
for (; i < p; i++) /*后半部分得低分*/
{
stu[sortArr[0][i].located].soc = 90;
}
}
/*以下类似*/
if (q >= 1)
{
sort (sortArr[1], sortArr[1] + q, cmp);
for (i = 0; i < q / 2; i++)
{
stu[sortArr[1][i].located].soc = 85;
}
for (; i < q; i++)
{
stu[sortArr[1][i].located].soc = 80;
}
} if (r >= 1)
{
sort (sortArr[2], sortArr[2] + r, cmp);
for (i = 0; i < r / 2; i++)
{
stu[sortArr[2][i].located].soc = 75;
}
for (; i < r; i++)
{
stu[sortArr[2][i].located].soc = 70;
}
} if (k >= 1)
{
sort (sortArr[3], sortArr[3] + k, cmp);
for (i = 0; i < k / 2; i++)
{
stu[sortArr[3][i].located].soc = 65;
}
for (; i < k; i++)
{
stu[sortArr[3][i].located].soc = 60;
}
} for (i = 0; i < num; i++)
{
cout << stu[i].soc << endl;
}
cout << endl;
}
system ("pause");
return 0;
}
杭电OJ—— 1084 What Is Your Grade?的更多相关文章
- C#利用POST实现杭电oj的AC自动机器人,AC率高达50%~~
暑假集训虽然很快乐,偶尔也会比较枯燥,,这个时候就需要自娱自乐... 然后看hdu的排行榜发现,除了一些是虚拟测评机的账号以外,有几个都是AC自动机器人 然后发现有一位作者是用网页填表然后按钮模拟,, ...
- 杭电oj 2095 & 异或^符号在C/C++中的使用
异或^符号,在平时的学习时可能遇到的不多,不过有时使用得当可以发挥意想不到的结果. 值得注意的是,异或运算是建立在二进制基础上的,所有运算过程都是按位异或(即相同为0,不同为1,也称模二加),得到最终 ...
- 用python爬取杭电oj的数据
暑假集训主要是在杭电oj上面刷题,白天与算法作斗争,晚上望干点自己喜欢的事情! 首先,确定要爬取哪些数据: 如上图所示,题目ID,名称,accepted,submissions,都很有用. 查看源代码 ...
- 杭电oj 4004---The Frog Games java解法
import java.util.Arrays; import java.util.Scanner; //杭电oj 4004 //解题思路:利用二分法查找,即先选取跳跃距离的区间,从最大到最小, // ...
- 『ACM C++』HDU杭电OJ | 1415 - Jugs (灌水定理引申)
今天总算开学了,当了班长就是麻烦,明明自己没买书却要带着一波人去领书,那能怎么办呢,只能说我善人心肠哈哈哈,不过我脑子里突然浮起一个念头,大二还要不要继续当这个班委呢,既然已经体验过就可以适当放下了吧 ...
- 杭电oj————2057(java)
question:A+ B again 思路:额,没啥思路/捂脸,用java的long包里的方法,很简单,只是有几次WA,有几点要注意一下 注意:如果数字有加号要删除掉,这里用到了正则表达式“\\+” ...
- 爬取杭电oj所有题目
杭电oj并没有反爬 所以直接爬就好了 直接贴源码(参数可改,循环次数可改,存储路径可改) import requests from bs4 import BeautifulSoup import ti ...
- 杭电OJ——1198 Farm Irrigation (并查集)
畅通工程 Problem Description 某省调查城镇交通状况,得到现有城镇道路统计表,表中列出了每条道路直接连通的城镇.省政府"畅通工程"的目标是使全省任何两个城镇间都可 ...
- 杭电OJ——1007 Quoit Design(最近点对问题)
Quoit Design Problem Description Have you ever played quoit in a playground? Quoit is a game in whic ...
随机推荐
- Android SDK 更新时修改hosts文件仍然无法更新,可试试这个方法……
Android SDK 更新时修改hosts文件仍然无法更新,此时必定万分蛋疼.在hosts文件中更换了各种ip,仍然解决不了!!!!!!!!!!!!!!? 第一步: 打开此软件,等待服务器连接 第二 ...
- JavaScript权威指南阅读笔记3
第六章 对象 1.首先是先介绍了对象直接量的格式:对象直接量就是1.由若干个名/值对组成的映射表,2名/值对中间由冒号分割,3名值对之间由逗号分割,4整个映射表由花括号括起来.这样就组成了一个对象直接 ...
- php pdf word excel 操作方法
很早的时候,用php生成execl都是件麻烦的事,我一般都会用csv来替代,现在这类工具就很多了,并且比较成熟了.不光有excel的,word,pdf. 1,php excelreader操作exce ...
- ZOJ 3745 Salary Increasing
Description Edward has established a company with n staffs. He is such a kind man that he did Q time ...
- Mysql基础教程——mysql之一
教程列表:http://www.dxzy163.com/view/index7627.html 41 存储过程 40 全文索引与停止词 39 索引的管 38 索引概念 37 数据库备份与恢复 36 事 ...
- JavaScript 之 Cookie
JavaScript是运行在客户端的脚本,因此一般是不能够设置Session的,因为Session是运行在服务器端的. 而cookie是运行在客户端的,所以可以用JS来设置cookie. 假设有这样一 ...
- windows多线程没那么难
windows多线程没那么难 作者:vpoet mail:vpoet_sir@163.com 上一博文中我们引入了CreateThread()多线程编程一个简单的例子,事实上我说windows 多线程 ...
- C++ classics
common Business-Oriented LanguageBASIC(Beginner's All-purpose Symbolic Instruction Code)1972 C1983 C ...
- Linux NFS服务器的安装与配置(转载)
一.NFS服务简介 NFS 是Network File System的缩写,即网络文件系统.一种使用于分散式文件系统的协定,由Sun公司开发,于1984年向外公布.功能是通过网络让不同的机器.不同的操 ...
- #include<math.h>
1.sin(a)类:a是弧度值: 2.abs(b):结果是b的绝对值: 3.exp(c):exp()用来计算以e为底的x次方值,即ex值,然后将结果返回.返回值: 返回e的x次方计算结果. 4.log ...