이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/**
* \`*-.
* ) _`-.
* . : `. .
* : _ ' \
* ; *` _. `*-._
* `-.-' `-.
* ; ` `.
* :. . \
* . \ . : .-' .
* ' `+.; ; ' :
* : ' | ; ;-.
* ; ' : :`-: _.`* ;
* [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... |