标签:namespace std div ble class include algo += operator
1 //这道题让我想起来班主任的名言,你上课耽误1分钟,大家40个人,就耽误了大家40分钟。一样的道理,越靠前的人耽误的人越多,所以让快的人尽量靠前。 2 #include <cstdio> 3 #include <algorithm> 4 using namespace std; 5 struct dat 6 { 7 int id,tim; 8 friend bool operator < (dat a,dat b) 9 { 10 return a.tim < b.tim; 11 } 12 } vec[1010]; 13 int n; 14 double tot,sum; 15 int main() 16 { 17 scanf("%d",&n); 18 for (int i = 1;i <= n;i++) 19 { 20 scanf("%d",&vec[i].tim); 21 vec[i].id = i; 22 } 23 sort(vec + 1,vec + n + 1); 24 for (int i = 1;i <= n;i++) 25 { 26 tot += sum; 27 sum += vec[i].tim; 28 } 29 for (int i = 1;i <= n;i++) 30 printf("%d ",vec[i].id); 31 printf("\n"); 32 printf("%.2lf\n",tot / n); 33 return 0; 34 }
标签:namespace std div ble class include algo += operator
原文地址:https://www.cnblogs.com/iat14/p/11143389.html