注意:学分和成绩都是浮点型,GPA不存在,输出-1
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
int n = sc.nextInt();
double sSum = 0;
double pSum = 0;
while (n-->0){
double s = sc.nextDouble();
double p = sc.nextDouble();
if (p==-1) {
continue;
}
sSum += s;
if (p<60) {
continue;
}
if (p<70) {
pSum += s;
}else if(p<80) {
pSum += s*2;
}else if (p<90) {
pSum += s*3;
}else if(p<=100){
pSum += s*4;
}
}
if (sSum==0) {
System.out.println(-1);
}else{
System.out.printf("%.2f",pSum/sSum);
System.out.println();
}
}
}
}