题目大意
给一堆题目。包含题目的tag,提交数,通过数,然后通过率在030%的题目难度为5,在30%60%之间的难度为4,在60%~100%之间的难度为3;然后让你按字典序输入题目的tag以及它的难度
样例输入
4
math 100 90
algorithm 10 8
string 50 1
dp 100 50
样例输出
algorithm 3
dp 4
math 3
string 5
题解
计算题目的难度,然后sort+cmp对进行排序,输出就可以了。水题。。。
AC代码
#include<iostream>
#include<algorithm>
using namespace std;
typedef struct problem{
string name;
double x ,y;
int diff;
}pro;
pro p[105];
int Diff(double x , double y){
double t = 0;
int d;
t = y / x;
if(t >= 0 && t <= 0.3){
d = 5;
}else if(t > 0.3 && t <= 0.6){
d = 4;
}else if(t > 0.6 && t <=1){
d = 3;
}
return d;
}
bool cmp(pro p1 , pro p2){
return p1.name < p2.name;
}
int main(){
int n;
cin >> n;
for(int i = 0;i < n;i++){
cin >> p[i].name >> p[i].x >> p[i].y;
p[i].diff = Diff(p[i].x , p[i].y);
}
sort(p , p + n , cmp);
for(int i = 0;i < n;i++){
cout << p[i].name <<" "<< p[i].diff << endl;
}
return 0;
}