Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <set>
- #include <cmath>
- #include <algorithm>
- using namespace std;
- float dist(vector<int> x1, vector<int> x2) {
- int sum1, sum2;
- float res;
- sum1 = abs(x1[0] - x2[0]);
- sum2 = abs(x1[1] - x2[1]);
- res = sqrt(pow(sum1, 2) + pow(sum2, 2));
- return res;
- }
- int main()
- {
- vector<vector<int>> homes;
- int n, c;
- long p;
- cin >> n >> c >> p;
- for (int i = 0; i < n; i++) {
- int x, y;
- vector<int> a;
- cin >> x >> y;
- a.push_back(x);
- a.push_back(y);
- homes.push_back(a);
- a.clear();
- }
- vector<float> opt;
- vector<int> net;
- int x_net, y_net;
- cin >> x_net >> y_net;
- net.push_back(x_net);
- net.push_back(y_net);
- for (int i = 0; i < n; i++) {
- float length;
- length = dist(net, homes[i]);
- for (int j = 0; j < n; j++) {
- if (i != j) { length += dist(homes[i], homes[j]); }
- }
- if (length - (int)length >= 0.5)
- opt.push_back(ceil(length) * c);
- else
- opt.push_back(floor(length) * c);
- }
- float ans;
- ans = *min_element(opt.begin(), opt.end());
- if (ans <= p) { cout << "YES"; }
- else { cout << "NO"; }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement