weird

To be honest,I don’t really want to blog this article.The first reason is that I am not much sure what topic of it should be named ,but finally I call it “weird”.Oh,it is strange.And the second reason why I reckon this is that there are many blogs on this subject.But I have to still say something.

Here are three pictures to describe this problem:在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
I think I’d better paste the test data:
Sample Input
8 20
GuGuDong 96 -3 40(3) 0 0 1 -8 0
hrz 107 67 -3 0 0 82 0 0
TT 120(3) 30 10(1) -3 0 47 21(2) -2
OMRailgun 0 -99 -8 0 -666 -10086 0 -9999996
yjq -2 37(2) 13 -1 0 113(2) 79(1) -1
Zjm 0 0 57(5) 0 0 99(3) -7 0
A little bit of a mess,isn’t it?
And the next you can see the code:

#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
using namespace std;
using std::setw; 
struct student{
 char name[20];//姓名 
 int time;//时间 
 int ac;//做出的题 
};
struct student stu[10000];
bool cmp(student s,student t){//比较函数,用于sort排序
 if(s.ac != t.ac) return s.ac>t.ac;
 if(s.ac == t.ac && s.time == t.time) return s.name<t.name;
 if(s.ac == t.ac) return s.time<t.time;
 return false;
};
int main(){
 int wa,n,m,cost,k;//错误,题数,单位罚时,耗时 
 string str;
 cin>>n>>m;
 k=0;
 while(cin>>stu[k].name){
  for(int i=0;i<n;i++){
   wa=0;cost=0;
   cin>>str;
   if(str[0]=='0' || str[0]=='-')
    continue;
   for(int j=0;j<str.length();j++){
    if(str[j]=='('){
     j++;
     while(str[j] !=')'){
      wa=wa*10+str[j]-'0';
      j++;
     }
     break; 
    }
    else cost=cost*10+str[j]-'0';
   }
   stu[k].ac++;
   stu[k].time +=cost+wa*m;
  }
  k++;
 } 
 sort(stu,stu+k,cmp);//对齐
 for(int h=0;h<k;h++){
  cout.flags(ios::left);
  cout << setw(10) << stu[h].name << " ";
  cout.flags(ios::right);
  cout << setw(2) << stu[h].ac << " ";
  cout << setw(4) << stu[h].time;
  cout << endl;
 }
 return 0;
}

Explannation:
Obviously,we should definite a structure of students or you can say competitors.And then count the number of problems they solved,calculate time punishment.Here are the rules,for example,GuGuDong,actually he solved three problems,but the second problem he had made mistakes three times.Therefore,as the punishment,it takes him 3*20=60 minutes.In total,his scores:96+40+1+60=197;
you can use the regularity to solve all of details of this problem.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值