排队接水求调
  • 板块灌水区
  • 楼主HypixelSkyblock
  • 当前回复5
  • 已保存回复5
  • 发布时间2024/8/12 08:52
  • 上次更新2024/8/12 10:11:10
查看原帖
排队接水求调
983008
HypixelSkyblock楼主2024/8/12 08:52
#include<bits/stdc++.h>
using namespace std;

struct Man{
    int id;
    int time;
};
vector<Man> man;
bool cmp(const Man& a, const Man& b){
    return a.time < b.time;  
}

int main(){
    int n;

    cin >> n;

    man.resize(n);
    vector<int> timeNeeds(n,0);

    for (int i = 1;i <= n;i++){
        man[i].id = i;
        cin >> man[i].time;
    }    

    sort(man.begin(), man.end(),cmp);

    for (int i = 1; i <= n; i++)
        cout << man[i].id << " ";
    cout << endl;
    double s = 0;
    for (int i = 1;i <= n;i++){
        s += man[i].time * (n - i);
    }
    printf("%.2f",s / n);
    return 0;
}

序号能正常输出,大蒟蒻实在是看不出来问题了,每次调试都有不同的结果。

2024/8/12 08:52
加载中...