제출 #1316366

#제출 시각아이디문제언어결과실행 시간메모리
1316366djsksbrbfBest Place (NOI17_bestplace)C++20
100 / 100
26 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, 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; }; sort(x + 1, x + n + 1); sort(y + 1, y + n + 1); if(n % 2){ cout << x[(n + 1) / 2] << ' ' << y[(n + 1) / 2] << endl; } else{ //x[(n + 1) / 2], y[(n + 1) / 2] pii cur = {x[(n + 1) / 2], y[(n+ 1) / 2]}; if(check(cur.fi, 1) + check(cur.se, 0) > check(x[(n + 1) / 2 + 1], 1) + check(y[(n + 1) / 2], 0))cur = {x[(n + 1) / 2 + 1], y[(n + 1) / 2]}; if(check(cur.fi, 1) + check(cur.se, 0) > check(x[(n + 1) / 2 + 1], 1) + check(y[(n + 1) / 2 + 1], 0))cur = {x[(n + 1) / 2 + 1], y[(n + 1) / 2 + 1]}; if(check(cur.fi, 1) + check(cur.se, 0) > check(x[(n + 1) / 2], 1) + check(y[(n + 1) / 2 + 1], 0))cur = {x[(n + 1) / 2 + 1], y[(n + 1) / 2 + 1]}; cout << cur.fi << ' ' << cur.se << 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...