제출 #1316363

#제출 시각아이디문제언어결과실행 시간메모리
1316363djsksbrbfBest Place (NOI17_bestplace)C++20
48 / 100
20 ms1980 KiB
#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) -> int{
      int ans = 0;
      for(int i = 1 ; i <= n ; i++)ans += abs(xe - x[i]);
      return ans;
   };
   sort(x + 1, x + n + 1);
   if(n % 2){
      cout << x[(n + 1) / 2] << " 0 " << endl;
   }
   else{
      //check x[(n + 1) / 2] and x[(n + 1) / 2 + 1]
      if(check(x[(n + 1) / 2]) < check(x[(n + 1) / 2 + 1]))cout << x[(n + 1) / 2] << " 0" << endl;
      else cout << x[(n + 1) / 2 + 1] << " 0 " << endl;
   }
   
   return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...