0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-23 22:48:48 +00:00

#784. 0826农夫约的假期 (shuru)

https://sjzezoj.com/submission/22861
This commit is contained in:
Baoshuo Ren 2021-08-26 13:37:28 +08:00 committed by Baoshuo Ren
parent 04ca89fcc7
commit d74aba08ef
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

27
S2OJ/784/784.cpp Normal file
View File

@ -0,0 +1,27 @@
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
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;
}