Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- #include <utility>
- #include <string>
- #include <math.h>
- using namespace std;
- typedef long long ll;
- int main()
- {
- ios_base::sync_with_stdio(false);
- cin.tie(0);
- int x1, y1, x2, y2;
- int n;
- cin >> x1 >> y1 >> x2 >> y2 >> n;
- vector <pair<int, int>> cs(n);
- vector <int> t(n);
- for (int i = 0; i < n; i++) {
- int a, b;
- cin >> a >> b;
- cs[i] = { a, b };
- cin >> t[i];
- }
- double ans = 1e9;
- for (int i = 0; i < n; i++) {
- double c = 0;
- c += sqrt((cs[i].first - x1) * (cs[i].first - x1) + (cs[i].second - y1) * (cs[i].second - y1));
- c += t[i];
- c += sqrt((x2 - cs[i].first) * (x2 - cs[i].first) + (y2 - cs[i].second) * (y2 - cs[i].second));
- ans = min(ans, c);
- }
- cout << fixed;
- cout.precision(10);
- cout << ans;
- }
Advertisement
Add Comment
Please, Sign In to add comment