| Run ID | 作者 | 问题 | 语言 | 测评结果 | 时间 | 内存 | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 78121 | sh25_wangtaojie | [贪心算法]排队接水 | C++ | 通过 | 0 MS | 248 KB | 848 | 2025-12-26 15:23:36 |
#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; }