Run ID 作者 问题 语言 测评结果 时间 内存 代码长度 提交时间
76338 sh25_shenpy [贪心算法]排队接水 C++ 通过 0 MS 252 KB 519 2025-12-19 14:39:26

Tests(1/1):


#include<bits/stdc++.h> using namespace std; struct P{ int id; int time; }; bool cmp(P a, P b) { return a.time<b.time; } int main(){ int n; cin>>n; P p[1005]; for(int i=0; i<n; i++) { cin>> p[i].time; p[i].id = i+1; } sort(p, p+n, cmp); double total = 0; for(int i=0; i<n; i++) { cout << p[i].id << " "; total += p[i].time * (n-i-1); } cout << endl << fixed << setprecision(2) << total/n; return 0; }


测评信息: