From d74aba08ef4f066a90008034eb78521e54e9dc57 Mon Sep 17 00:00:00 2001 From: Ren Baoshuo Date: Thu, 26 Aug 2021 13:37:28 +0800 Subject: [PATCH] =?UTF-8?q?#784.=200826=E5=86=9C=E5=A4=AB=E7=BA=A6?= =?UTF-8?q?=E7=9A=84=E5=81=87=E6=9C=9F=20(shuru)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://sjzezoj.com/submission/22861 --- S2OJ/784/784.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 S2OJ/784/784.cpp diff --git a/S2OJ/784/784.cpp b/S2OJ/784/784.cpp new file mode 100644 index 00000000..f5c13d3b --- /dev/null +++ b/S2OJ/784/784.cpp @@ -0,0 +1,27 @@ +#pragma GCC optimize("Ofast") + +#include + +using namespace std; + +int n, m, z, x[100005], y[100005]; +long long ans, mx, my, az; + +int main() { + std::ios::sync_with_stdio(false); + cin >> n >> m >> z; + for (int i = 1; i <= m; i++) { + cin >> x[i] >> y[i] >> z; + az += z; + } + sort(x + 1, x + 1 + m); + sort(y + 1, y + 1 + m); + mx = x[m + 1 >> 1]; + my = y[m + 1 >> 1]; + for (int i = 1; i <= m; i++) { + ans += abs(x[i] - mx) + abs(y[i] - my); + } + cout << ans + az << endl; + cout << mx << ' ' << my << endl; + return 0; +}