提交时间:2025-12-26 15:39:44
运行 ID: 78341
#include <iostream> #include <vector> #include <algorithm> #include <iomanip> using namespace std; struct Person { int id; int time; }; bool compare(const Person& a, const Person& b) { return a.time < b.time; } int main() { int n; cin >> n; vector<Person> people(n); for (int i = 0; i < n; ++i) { cin >> people[i].time; people[i].id = i + 1; } sort(people.begin(), people.end(), compare); for (int i = 0; i < n; ++i) { cout << people[i].id; if (i < n - 1) cout << " "; } cout << endl; double total_wait = 0, current_time = 0; for (int i = 0; i < n - 1; ++i) { current_time += people[i].time; total_wait += current_time; } cout << fixed << setprecision(2) << total_wait / n << endl; return 0; }