/*
实际成绩 绩点
90——100 4.0
85——89 3.7
82——84 3.3
78——81 3.0
75——77 2.7
72——74 2.3
68——71 2.0
64——67 1.5
60——63 1.0
60以下 0
1.一门课程的学分绩点=该课绩点*该课学分
2.总评绩点=所有学科绩点之和/所有课程学分之和
现要求你编写程序求出某人A的总评绩点(GPA)。
*/
#include <stdio.h>
#include <stdlib.h>
int binSearch(int A[],int x){
int low=0,high=9,mid;
while(low<=high){
mid = (low+high)/2;
if(A[mid]==x) return mid;
else if(A[mid]<x) low = mid+1;
else high = mid-1;
}
return low-1;
}
int main() {
int match[10]={0,60,64,68,72,75,78,82,85,90};
float gpa[10]={0,1,1.5,2.0,2.3,2.7,3.0,3.3,3.7,4.0};
int n;
while(scanf("%d",&n)==1){
int total_study_point = 0;
float total_gpa = 0;
int *list=(int *)malloc(sizeof(int)*n);
for(int i = 0;i<n;i++){
int temp;
scanf("%d",&temp);
total_study_point+=temp;
list[i]=temp;
};
for(int i = 0;i<n;i++){
int temp;
scanf("%d",&temp);
total_gpa+=gpa[binSearch(match,temp)]*list[i];
};
printf("%.2f\n", total_gpa / total_study_point);
}
return 0;
}