HUST Online Judge WebBoard
Problem 1198 >> hdu2093
201916040298 @ 2019-11-21 15:08:08
[ Quote ] [ Edit ] [ Delete ] 1#
#include<cstdio>
#include<string>
#include<cstdlib>
#include<iostream>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
#include<cctype>
#include<array>
#include<numeric>
#include<set>
#include<map>
#include<queue>
#include<ctime>
#include<list>
#include<sstream>
using namespace std;
struct Test
{
public:
string name;
int ana = 0;
int time = 0;
};
int m;
bool cmp(const Test a, const Test b) {
if (a.ana != b.ana) {
return a.ana > b.ana;
}
else if (a.time != b.time) {
return a.time < b.time;
}
return a.name < b.name;
}
//int* read(string s, int *A);
//int punish(int x);
void Print(Test a);
int main()
{
int n;
vector<Test> student;
string s;
int A[2] = { 0 };
cin >> n; m = 20;
int p = 6;
while (cin >> s) {
Test temp;
temp.name = s;
for (int i = 0; i < n; i++) {
int temp1, temp2;
if (scanf("%d(%d)", &temp1, &temp2) == 2) { //带括号直接读入两个数据
temp.ana++;
temp.time += (temp2 * m + temp1);
}
else { //若只读入一个数据
if (temp1 > 0) {
temp.ana++;
temp.time += temp1;
}
}
/*
string s2;
cin >> s2;
read(s2, A);
if (A[0] > 0) {
temp.ana++;
temp.time += A[0];
temp.time += A[1];
}
*/
}
student.push_back(temp);
}
sort(student.begin(), student.end(), cmp);
for (auto i = student.begin(); i != student.end(); ++i) {
Print(*i);
}
return 0;
}
/* int* read(string s,int *A) {
int tag = 0;
for (auto &i : s) {
if (i == '('||i==')') {
i = ' ';
tag = 1;
}
}
if (tag == 1) {
vector<string> ana;
stringstream ss(s);
string t;
while (ss >> t) {
ana.push_back(t);
}
A[0] = stoi(ana[0]);
A[1] = punish(stoi(ana[1]));
}
else {
A[0] = stoi(s);
A[1] = 0;
}
return A;
}
int punish(int x) {
return x * m;
}
*/
void Print(Test a) {
printf("%-10s %2d %4d\n", a.name.c_str(), a.ana, a.time);
}