답안 #869385

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
869385 2023-11-04T09:01:43 Z shdfshdfshdf 이상적인 도시 (IOI12_city) C++17
컴파일 오류
0 ms 0 KB
int DistanceSum(int n, int *x, int *y){
    int minx=4294967295, miny=4294967295;
    for (int a=0; a<n; a++) {
        minx=min(minx, x[a]);
        miny=min(miny, y[a]);
    }
    for (int a=0; a<n; a++) {
        x[a]-=minx;
        y[a]-=miny;
    }
    sort(x, x+n);
    sort(y, y+n);
    int bx=0, by=0;
    for (int a=0; a<n; a++) {
        bx+=x[a]-x[0];
        by+=y[a]-y[0];
    }
    int ans=bx+by;
    for (int a=1; a<n; a++) {
        bx-=(n-a)*(x[a]-x[a-1]);
        by-=(n-a)*(y[a]-y[a-1]);
        ans=(ans+bx+by)%1000000000;
    }
    return ans;
}

Compilation message

city.cpp: In function 'int DistanceSum(int, int*, int*)':
city.cpp:4:14: error: 'min' was not declared in this scope; did you mean 'miny'?
    4 |         minx=min(minx, x[a]);
      |              ^~~
      |              miny
city.cpp:11:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   11 |     sort(x, x+n);
      |     ^~~~
      |     short