답안 #804022

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
804022 2023-08-03T06:53:24 Z Dan4Life 이상적인 도시 (IOI12_city) C++17
23 / 100
27 ms 1152 KB
#include <bits/stdc++.h>
using namespace std;
using  ll = long long;
const ll MOD = (ll)1e9;

int DistanceSum(int N, int *X, int *Y) {
    ll ans = 0, tot = 0; 
    sort(X,X+N), sort(Y,Y+N);
    for(int j : {0,1}){
        tot = 0; sort(X,X+N);
        for(ll i = 0; i < N; i++){
            ans+=(1ll*X[i]*i-tot+MOD)%MOD;
            tot+=X[i], tot%=MOD; ans%=MOD;swap(X[i],Y[i]);
        }
    }
    return (int)ans;
}

Compilation message

city.cpp: In function 'int DistanceSum(int, int*, int*)':
city.cpp:9:13: warning: unused variable 'j' [-Wunused-variable]
    9 |     for(int j : {0,1}){
      |             ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 468 KB Output is correct
2 Correct 5 ms 468 KB Output is correct
3 Correct 12 ms 712 KB Output is correct
4 Correct 12 ms 724 KB Output is correct
5 Correct 24 ms 1036 KB Output is correct
6 Correct 27 ms 1132 KB Output is correct
7 Correct 27 ms 1132 KB Output is correct
8 Correct 24 ms 1136 KB Output is correct
9 Correct 24 ms 1108 KB Output is correct
10 Correct 24 ms 1152 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 468 KB Output isn't correct
2 Halted 0 ms 0 KB -