Advertisement
OIQ

Untitled

OIQ
Jan 26th, 2020
170
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. #include <utility>
  5. #include <string>
  6. #include <math.h>
  7.  
  8. using namespace std;
  9.  
  10. typedef long long ll;
  11.  
  12.  
  13. int main()
  14. {
  15.     ios_base::sync_with_stdio(false);
  16.     cin.tie(0);
  17.  
  18.     int x1, y1, x2, y2;
  19.     int n;
  20.     cin >> x1 >> y1 >> x2 >> y2 >> n;
  21.  
  22.     vector <pair<int, int>> cs(n);
  23.     vector <int> t(n);
  24.     for (int i = 0; i < n; i++) {
  25.         int a, b;
  26.         cin >> a >> b;
  27.         cs[i] = { a, b };
  28.         cin >> t[i];
  29.     }
  30.  
  31.     double ans = 1e9;
  32.  
  33.     for (int i = 0; i < n; i++) {
  34.         double c = 0;
  35.         c += sqrt((cs[i].first - x1) * (cs[i].first - x1) + (cs[i].second - y1) * (cs[i].second - y1));
  36.         c += t[i];
  37.         c += sqrt((x2 - cs[i].first) * (x2 - cs[i].first) + (y2 - cs[i].second) * (y2 - cs[i].second));
  38.         ans = min(ans, c);
  39.     }
  40.  
  41.     cout << fixed;
  42.     cout.precision(10);
  43.     cout << ans;
  44.  
  45. }
Advertisement
RAW Paste Data Copied
Advertisement