Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2016
1,102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.83 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. using namespace std;
  5.  
  6. typedef long long ll;
  7.  
  8. ll square(int x) {
  9.     return x * (ll) x;
  10. }
  11.  
  12. int main() {
  13.     ios_base::sync_with_stdio(false); cin.tie(0);
  14.  
  15.     int n, x1, y1, x2, y2;
  16.     cin >> n >> x1 >> y1 >> x2 >> y2;
  17.     vector< pair<ll, ll> > dist(n);
  18.     for (int i = 0; i < n; i++) {
  19.         int x, y;
  20.         cin >> x >> y;
  21.         dist[i].first = square(x - x1) + square(y - y1);
  22.         dist[i].second = square(x - x2) + square(y - y2);
  23.     }
  24.     dist.push_back({0, 0});
  25.  
  26.     ll result = 8e18;
  27.     for (auto i: dist) {
  28.         ll r1 = i.first;
  29.         ll r2 = 0;
  30.         for (auto j: dist) {
  31.             if (j.first > r1) {
  32.                 r2 = max(r2, j.second);
  33.             }
  34.         }
  35.         result = min(result, r1 + r2);
  36.     }
  37.  
  38.     cout << result << '\n';
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement