# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
987216 | CornerBoi | Best Place (NOI17_bestplace) | C++14 | 71 ms | 3152 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()
int main()
{
ll n;cin>>n;
vector<int> a_x(n);
vector<int> a_y(n);
for(size_t i = 0;i<n;i++)
{
cin>>a_x[i]>>a_y[i];
}
sort(all(a_x));
sort(all(a_y));
ll mini = LLONG_MAX;
ll loc = 0;
ll idx_start = (n/2)-5;
ll idx_end = (n/2)+5;
for(size_t i = max(0LL,idx_start);i<min(n,idx_end);i++)
{
ll curr = 0;
ll x = a_x[i];
ll y = a_y[i];
for(size_t j = 0;j<n;j++)
{
curr += abs(x-a_x[j]);
curr += abs(y-a_y[j]);
}
if(mini < curr){break;}
else {mini = min(mini,curr);loc = i;}
}
cout<<a_x[loc]<<" "<<a_y[loc]<<endl;
return 0;
}
Compilation message (stderr)
# | 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... |