답안 #544644

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
544644 2022-04-02T14:11:06 Z pokmui9909 점 모으기 (KOI13_collect) C++17
24 / 24
29 ms 2928 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

ll N, M;
ll X[100005];
ll Y[100005];

int main() {
    cin.tie(0) -> sync_with_stdio(false);
    
    cin >> N >> M;
    for(int i = 0; i < M; i++) {
        cin >> X[i] >> Y[i];
    }
    sort(X, X + M);
    sort(Y, Y + M);
    ll x = X[M / 2], y = Y[M / 2];
    ll ans = 0;
    for(int i = 0; i < M; i++) {
        ans += abs(x - X[i]);
        ans += abs(y - Y[i]);
    }
    cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 472 KB Output is correct
2 Correct 7 ms 812 KB Output is correct
3 Correct 3 ms 492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 1108 KB Output is correct
2 Correct 12 ms 1372 KB Output is correct
3 Correct 9 ms 1108 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 1492 KB Output is correct
2 Correct 16 ms 1748 KB Output is correct
3 Correct 18 ms 2068 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 2636 KB Output is correct
2 Correct 25 ms 2764 KB Output is correct
3 Correct 17 ms 2264 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 468 KB Output is correct
2 Correct 23 ms 2392 KB Output is correct
3 Correct 25 ms 2768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 2900 KB Output is correct
2 Correct 29 ms 2928 KB Output is correct
3 Correct 27 ms 2896 KB Output is correct