Submission #932834

#TimeUsernameProblemLanguageResultExecution timeMemory
932834ishat_jhaBest Place (NOI17_bestplace)C++14
23 / 100
90 ms2196 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long int #define ff first #define ss second void solvr() { ll n; cin >> n; vector<pair<ll, ll>> v(n); ll only_z = 1; for(ll i = 0; i < n; i++) { cin >> v[i].ff >> v[i].ss; if(v[i].ss != 0) { only_z = 0; } } if(n == 2) { cout << v[0].ff << " " << v[0].ss << endl; return; } else if(only_z = 1) { ll tt = 0; ll minn = LLONG_MAX; for(ll i = 0; i < 1000; i++) { ll sum = 0; for(ll j = 0; j < n; j++) { sum += abs(v[j].ff - i); } if(minn > sum) { tt = i; minn = sum; } } cout << tt << " " << 0 << endl; } else { pair<ll, ll> minn; ll mnn = LLONG_MAX; for(ll x = 0; x <= 100; x++) { for(ll y = 0; y <= 100; y++) { ll sum = 0; for(ll i = 0; i < n; i++) { sum += (abs(v[i].ff - x) + abs(v[i].ss - y)); } if(sum < mnn) { mnn = sum; minn = make_pair(x, y); } } } cout << minn.ff << " " << minn.ss << endl; } } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long int t = 1; //cin >> t; while(t--) { solvr(); } }

Compilation message (stderr)

bestplace.cpp: In function 'void solvr()':
bestplace.cpp:26:17: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   26 |  else if(only_z = 1)
      |          ~~~~~~~^~~
#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...