Linux安全网 - Linux操作系统_Linux 命令_Linux教程_Linux黑客

会员投稿 投稿指南 本期推荐:
搜索:
您的位置: Linux安全网 > Linux编程 > » 正文

HDOJ 1084 What Is Your Grade? 解题报告

来源: 未知 分享至:

http://acm.hdu.edu.cn/showproblem.php?pid=1084

模拟题,使用表驱动避免大量判断。注意当只有一个人做出n道题时( n < 5 && n > 0 ),他的分数+5。

Run ID Submit Time Judge Status Pro.ID Exe.Time Exe.Memory Code Len. Language Author
4255746 2011-07-25 22:01:25 Accepted 1084 0MS 348K 1954 B G++ GongZi
//HDOJ 1084 Code By NetBeans 6.9.1
#include <iostream>
#include
<cstdio>
#include
<memory.h>
#include
<algorithm>

using namespace std;

struct STUDTYPE
{
int order;
int solved_num;
long long time;
int score;
};

bool cmp_by_solve_num(STUDTYPE x, STUDTYPE y);
bool cmp_by_order(STUDTYPE x, STUDTYPE y);
int default_score[6] = {50, 60, 70, 80, 90, 100};

int main()
{
int N;
while(cin >> N && N > 0)
{
int solved[6];
memset(solved,
0, sizeof(solved));
STUDTYPE stud[N];
for(int i = 0; i < N; ++i)
{
int h, m, s;
scanf(
\"%d %d:%d:%d\", &stud[i].solved_num, &h, &m, &s);
stud[i].time
= h * 3600 + m * 60 + s;
stud[i].order
= i;
solved[stud[i].solved_num]
++;
}
sort(stud, stud
+ N, cmp_by_solve_num);
int first_half[6];
for( int i = 0; i < 6; ++i )
{
if( solved[i] == 1 )
{
first_half[i]
= 1;
}
else
{
first_half[i]
= solved[i] / 2;
}
}
for( int i = 0; i < N; ++i )
{
int num = stud[i].solved_num;
stud[i].score
= default_score[num];
if( first_half[num] > 0 && num < 5 && num > 0 )
{
stud[i].score
+=

Tags:
分享至:
最新图文资讯
1 2 3 4 5 6
验证码:点击我更换图片 理智评论文明上网,拒绝恶意谩骂 用户名:
关于我们 - 联系我们 - 广告服务 - 友情链接 - 网站地图 - 版权声明 - 发展历史