Advertisement
maxim_shlyahtin

0057

Jul 14th, 2022
1,002
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.28 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <set>
  4. #include <cmath>
  5. #include <algorithm>
  6.  
  7. using namespace std;
  8.  
  9.  
  10. float dist(vector<int> x1, vector<int> x2) {
  11.     int sum1, sum2;
  12.     float res;
  13.     sum1 = abs(x1[0] - x2[0]);
  14.     sum2 = abs(x1[1] - x2[1]);
  15.     res = sqrt(pow(sum1, 2) + pow(sum2, 2));
  16.     return  res;
  17. }
  18.  
  19.  
  20. int main()
  21. {  
  22.     vector<vector<int>> homes;
  23.     int n, c;
  24.     long p;
  25.     cin >> n >> c >> p;
  26.     for (int i = 0; i < n; i++) {
  27.         int x, y;
  28.         vector<int> a;
  29.         cin >> x >> y;
  30.         a.push_back(x);
  31.         a.push_back(y);
  32.         homes.push_back(a);
  33.         a.clear();
  34.     }
  35.     vector<float> opt;
  36.     vector<int> net;
  37.     int x_net, y_net;
  38.     cin >> x_net >> y_net;
  39.     net.push_back(x_net);
  40.     net.push_back(y_net);
  41.     for (int i = 0; i < n; i++) {
  42.         float length;
  43.         length = dist(net, homes[i]);
  44.         for (int j = 0; j < n; j++) {
  45.             if (i != j) { length += dist(homes[i], homes[j]); }
  46.  
  47.         }
  48.         if (length - (int)length >= 0.5)
  49.             opt.push_back(ceil(length) * c);
  50.         else
  51.             opt.push_back(floor(length) * c);
  52.     }
  53.     float ans;
  54.     ans = *min_element(opt.begin(), opt.end());
  55.     if (ans <= p) { cout << "YES"; }
  56.     else { cout << "NO"; }
  57. }
  58.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement