#include <bits/stdc++.h>
#define ll long long
using namespace std;
int n, x[100010], y[100010], px, py;
ll ax, ay, mxx, mxy;
int main() {
cin.tie(0)->sync_with_stdio(0);
cin >> n;
for(int i=1; i<=n; i++) {
cin >> x[i] >> y[i];
ax += x[i];
ay += y[i];
}
sort(x+1, x+n+1);
sort(y+1, y+n+1);
mxx = ax;
mxy = ay;
px = x[1];
py = y[1];
for(int i=2; i<=n; i++) {
ax -= (n-i+1)*(x[i]-x[i-1]);
ax += (i-1)*(x[i]-x[i-1]);
if(mxx < ax) {
ax = mxx;
px = x[i];
}
ay -= (n-i+1)*(y[i]-y[i-1]);
ay += (i-1)*(y[i]-y[i-1]);
if(mxy < ay) {
ay = mxy;
py = y[i];
}
}
cout << px << " " << py;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
724 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
1884 KB |
Output is correct |
2 |
Incorrect |
18 ms |
1884 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
600 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
28 ms |
2480 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |