题解 | #Grading#
Grading
https://www.nowcoder.com/practice/23e3244406724ffa8330760f640c8149
#include <iostream> //#include<cstdio> #include<cmath> using namespace std; int main() { double p,t,g1,g2,g3,gj; while (cin >> p>>t>>g1>>g2>>g3>>gj) { double score; if(fabs(g1-g2)<=t)score=(g1+g2)/2.0; else{ if((fabs(g3-g1)<=t||fabs(g3-g2)<=t)&&(!(fabs(g3-g1)<=t&&fabs(g3-g2)<=t))) { int min=fabs(g3-g1); int x=g1; if(min>=fabs(g3-g2))x=g2; score=(x+g3)/2.0; } else if((fabs(g3-g1)<=t&&fabs(g3-g2)<=t)){ double score1=max(g1,g2); score=max(score1,g3); } else if(fabs(g3-g1)>t&&fabs(g3-g2)>t){ score=gj; } } printf("%.1f",score); } }