提交时间:2025-12-05 15:32:46

运行 ID: 75214

#include <iostream> #include <cmath> #include <vector> #include <algorithm> using namespace std; int main() { int n; cin >> n; vector<pair<pair<double, double>, int>> roofs(n); for (int i = 0; i < n; ++i) { double x, y; int people; cin >> x >> y >> people; roofs[i] = {{x, y}, people}; } // 按距离大本营排序 sort(roofs.begin(), roofs.end(), [](const auto& a, const auto& b) { double distA = sqrt(a.first.first * a.first.first + a.first.second * a.first.second); double distB = sqrt(b.first.first * b.first.first + b.first.second * b.first.second); return distA < distB; }); double totalTime = 0; for (const auto& roof : roofs) { double dist = sqrt(roof.first.first * roof.first.first + roof.first.second * roof.first.second); totalTime += 2 * dist / 50 + roof.second + 0.5 * roof.second; } cout << static_cast<int>(ceil(totalTime)) << endl; return 0; }