#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <ll, ll> pii;
#define fi first
#define se second
#define pb push_back
const int MOD = 1e9;
const int MAX = 2e5 + 5;
const int dx[4] = {0, 0, 1, -1};
const int dy[4] = {1, -1, 0, 0};
#define int ll
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int n; cin >> n;
int x[n + 5], y[n + 6];
for(int i = 1 ; i <= n ; i++)cin >> x[i] >> y[i];
auto check = [&](int xe, bool use) -> int{
int ans = 0;
for(int i = 1 ; i <= n ; i++){
int t = 0;
if(use == 1)t = abs(x[i] - xe);
else t = abs(y[i] - xe);
ans += t;
}
return ans;
};
pii ans = {0, 0};
for(int xe = 0 ; xe <= 100 ; xe++){
for(int ye = 0 ; ye <= 100 ; ye++){
if(check(ans.fi, 1) + check(ans.se, 0) > check(xe, 1) + check(ye, 0)){
ans = {xe, ye};
}
}
}
cout << ans.fi << ' ' << ans.se << endl;
return 0;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |