杭电acm 1084 What Is Your Grade? 比较考人的简单题

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

struct Point{
      int p;
      int s;
      int pos;
      int t;
};

Point p[105];
int n;
int sum[6],tol[6];

bool cmp1(const Point& lhs,const Point& rhs)//对所有的成员按照解题数从小到大排序,如解题数相同则按照时间从少到多排序
{
      if(lhs.p == rhs.p)
            return lhs.t<rhs.t;
      else
            return lhs.p < rhs.p;
}

bool cmp2(const Point& lhs,const Point& rhs)//按照编号排序
{
      return lhs.pos < rhs.pos;
}

int main()
{
      while(scanf("%d",&n)!=EOF && (n>=0))
      {
            int co,h,m,s;
            memset(sum,0,sizeof(sum));
            memset(tol,0,sizeof(tol));
            for(int i=0;i<n;i++)
            {
                  scanf("%d %d:%d:%d",&co,&h,&m,&s);
                  p[i].pos = i;
                  sum[co]++;//解题数相同的有多少人
                  p[i].p = co;
                  p[i].t = h*3600 + m*60 + s;
            }
            for(int i=1;i<=5;i++)//这是求出解题数少于i道的总人数
            {
                  tol[i] = tol[i-1]+sum[i-1];
            }
            sort(p,p+n,cmp1);
            for(int i=0;i<n;i++)
            {
                  p[i].s = p[i].p*10+50;
                  if(p[i].s == 100 || p[i].s == 50)   continue;
                  if(i-tol[p[i].p] < sum[p[i].p]/2)
                        p[i].s += 5;
            }
            sort(p,p+n,cmp2);
            for(int i=0;i<n;i++)
            {
                  printf("%d\n",p[i].s);
            }
            printf("\n");
      }
      return 0;
}

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值