求助!

P1223 排队接水

@[nowhere2009](/user/606401) 仔细看题 第二行为这种排列方案下的平均等待时间(输出结果精确到小数点后两位)。
by chaichunyang @ 2022-03-31 20:46:22


@[chaichunyang](/user/170603) “这种方案下”是什么意思我没太理解
by nowhere2009 @ 2022-03-31 20:49:09


@[nowhere2009](/user/606401) 就是你输出的方案 ~~我感觉你是对等待时间不太理解~~
by chaichunyang @ 2022-03-31 20:51:06


以下是本蒟蒻的代码可参考: ```cpp #include<bits/stdc++.h> using namespace std; struct Prsn{ int sqnce; int time; }a[1005]; bool cmp(Prsn x, Prsn y){ if(x.time != y.time){ return x.time < y.time; }else{ return x.sqnce < y.sqnce; } } int main() { int n; cin >> n; for(int i=1; i<=n; i++){ a[i].sqnce = i; cin >> a[i].time; } sort(a, a+n+1, cmp); for(int i=1; i<=n; i++){ cout << a[i].sqnce << " "; } cout << endl; double sum = 0; for(int i=1; i<=n; i++){ sum += a[i].time * (n-i); } cout << fixed << setprecision(2) << sum/n; return 0; } ``` 这样的答案好像挺差的了吧QwQ #### 注: # **禁止抄袭**
by YueYie44 @ 2022-05-03 15:59:29


|