fork(2) download
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. struct Point
  7. {
  8. long x;
  9. long y;
  10.  
  11. Point() : x(0), y(0) {}
  12.  
  13. Point(Point &point)
  14. {
  15. x = point.x;
  16. y = point.y;
  17. }
  18. };
  19.  
  20. int main()
  21. {
  22. int n;
  23. Point temp;
  24. cin >> n;
  25.  
  26. // first point
  27. cin >> temp.x >> temp.y;
  28. Point tr(temp); // top right
  29. Point tl(temp); // top left
  30. Point br(temp); // bottom right
  31. Point bl(temp); // bottom left
  32.  
  33. n--;
  34.  
  35. while(n--)
  36. {
  37. cin >> temp.x >> temp.y;
  38.  
  39. if(temp.x <= tl.x && temp.y >= tl.y)
  40. tl = temp;
  41. if(temp.x >= tr.x && temp.y >= tr.y)
  42. tr = temp;
  43. if(temp.x <= bl.x && temp.y <= bl.y)
  44. bl = temp;
  45. if(temp.x >= br.x && temp.y <= br.y)
  46. br = temp;
  47. }
  48.  
  49. long d1 = abs(tr.x - bl.x) + abs(tr.y - bl.y);
  50. long d2 = abs(tl.x - br.x) + abs(tl.y - br.y);
  51. long d3 = abs(tr.x - tl.x) + abs(tr.y - tl.y);
  52. long d4 = abs(bl.x - br.x) + abs(bl.y - br.y);
  53. long d5 = abs(tl.x - bl.x) + abs(tl.y - bl.y);
  54. long d6 = abs(tr.x - br.x) + abs(tr.y - br.y);
  55.  
  56. long result = max(max(d1, d2), max(d3, d4));
  57. result = max(result, max(d5, d6));
  58.  
  59. cout << result << endl;
  60.  
  61. return 0;
  62. }
  63.  
Success #stdin #stdout 0s 15240KB
stdin
3
2 3
5 2
0 1
stdout
6