This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/**
* \`*-.
* ) _`-.
* . : `. .
* : _ ' \
* ; *` _. `*-._
* `-.-' `-.
* ; ` `.
* :. . \
* . \ . : .-' .
* ' `+.; ; ' :
* : ' | ; ;-.
* ; ' : :`-: _.`* ;
* [VĐ] .*' / .*' ; .*`- +' `*'
* `*-* `*-* `*-*'
**/
/** HELLO WOLRD**/
#include <bits/stdc++.h>
#define NAME "main"
#define data DANG
#define ii pair<int64_t , int64_t>
#define fi first
#define se second
using namespace std;
const int64_t INF64 = 0x3f3f3f3f3f3f3f3f;
const int INF32 = 0x3f3f3f3f;
const int N = 1e5;
int n;
int64_t x[N + 2] , y[N + 2] , a[N + 2] , b[N + 2];
int64_t sum = INF64 , res1 , res2;
void init(){
cin >> n;
for(int i = 1 ; i <= n ; i++)
cin >> x[i] >> y[i];
}
void solve(){
sort(x + 1 , x + n + 1);
sort(y + 1 , y + n + 1);
for(int i = 1 ; i <= n ; i++)
a[i] = x[i] + a[i - 1];
for(int i =1 ; i <= n ; i++)
b[i] = y[i] + b[i - 1];
sum = INF64;
for(int i = 1 ; i <= n ; i++){
int64_t tmp = (a[n] - a[i] - x[i] * (n - i)) + (x[i] * (i - 1) - a[i - 1]);
if(tmp < sum){
sum = tmp;
res1 = x[i];
}
}
cout << res1 << " ";
sum = INF64;
for(int i = 1 ; i <= n ; i++){
int64_t tmp = (b[n] - b[i] - y[i] * (n - i)) + (y[i] * (i - 1) - b[i - 1]);
if(tmp < sum){
sum = tmp;
res2 = y[i];
}
}
cout << res2;
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
init();
solve();
}
# | 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... |