为什么不能用sort?
by XeCtera @ 2023-07-16 22:34:12
谁说不能用 sort。
by LegendaryGrandmaster @ 2023-07-16 22:34:39
谁说不能用 sort。
by cxqghzj @ 2023-07-17 00:00:22
贪心题不就应该用sort吗?
by ZengYilin_Lean @ 2023-07-17 07:03:19
看看我的代码(主函数):
```cpp
scanf("%d",&n);
for(int i=0;i<n;i++)
{
a[i].id=i+1;
scanf("%d",&a[i].time);
}
sort(a,a+n,cmp);
for(int i=0;i<n;i++)
{
printf("%d ",a[i].id);
ans+=a[i].time*(n-i-1.0);
}
ans/=n;
printf("\n%.2lf",ans);
return 0;
```
by francais @ 2023-10-06 13:27:51