题解 | #Grading#
Grading
https://www.nowcoder.com/practice/23e3244406724ffa8330760f640c8149
#include <iostream> #include <algorithm> #include <cmath> using namespace std; int main() { int p, t, g1, g2, g3, gj; while(cin >> p >> t >> g1 >> g2 >> g3 >> gj) { if(abs(g1 - g2) <= t) printf("%.1lf\n",(double)(g1 + g2) / 2); else if(abs(g1 - g3) <= t && abs(g2 - g3)) printf("%.1lf\n",(double)(g1 + g2 + g3) / 3); else if(abs(g1 - g3) <= t) printf("%.1lf\n",(double)(g1 + g3) / 2); else if(abs(g2 - g3) <= t) printf("%.1lf\n",(double)(g2 + g3) / 2); else printf("%.1lf\n", (double) gj); } return 0; } // 64 位输出请用 printf("%lld")