Skip to content

Commit

Permalink
Add 30315.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiyabye authored Dec 29, 2024
1 parent c989318 commit 7ef0857
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions 30xxx/30315.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;

void solve(void) {
int k; cin >> k;
vector<int> x(k), y(k);
for (int i=0; i<k; i++) cin >> x[i] >> y[i];

double ans = 1e9;
for (int i=0; i<k; i++) {
double sum = 0;
for (int j=0; j<k; j++) {
sum += hypot(x[i]-x[j], y[i]-y[j]);
}
ans = min(ans, sum / (k-1));
}
cout << fixed << setprecision(7) << ans;
}

int main(void) {
ios::sync_with_stdio(false);
cin.tie(nullptr);

solve();
return 0;
}

0 comments on commit 7ef0857

Please sign in to comment.