fork download
  1. // A - Longest Segment
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4.  
  5. int main() {
  6. int n;
  7. cin >> n;
  8. int arr[n][2];
  9. for (int i = 0; i < n; ++i) {
  10. cin >> arr[i][0] >> arr[i][1];
  11. }
  12.  
  13. double maxLen = 0;
  14. for (int i = 0; i < n; ++i) {
  15. for (int j = i + 1; j < n; ++j) {
  16. int x2 = arr[j][0];
  17. int x1 = arr[i][0];
  18. int y2 = arr[j][1];
  19. int y1 = arr[i][1];
  20. double distance = sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
  21. if (distance > maxLen) {
  22. maxLen = distance;
  23. }
  24. }
  25. }
  26.  
  27. cout << fixed << setprecision(10) << maxLen;
  28.  
  29. return 0;
  30. }
Success #stdin #stdout 1.97s 5284KB
stdin
Standard input is empty
stdout
46339.7412595280