Submission #987216

#TimeUsernameProblemLanguageResultExecution timeMemory
987216CornerBoiBest Place (NOI17_bestplace)C++14
100 / 100
71 ms3152 KiB
#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)

bestplace.cpp: In function 'int main()':
bestplace.cpp:14:23: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   14 |     for(size_t i = 0;i<n;i++)
      |                      ~^~
bestplace.cpp:28:40: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'const long long int' [-Wsign-compare]
   28 |     for(size_t i = max(0LL,idx_start);i<min(n,idx_end);i++)
      |                                       ~^~~~~~~~~~~~~~~
bestplace.cpp:35:27: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   35 |         for(size_t j = 0;j<n;j++)
      |                          ~^~
#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...