답안 #869397

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
869397 2023-11-04T09:09:47 Z teacup 이상적인 도시 (IOI12_city) C++14
23 / 100
26 ms 1524 KB
#include <bits/stdc++.h>
using namespace std;
 
int DistanceSum(int N, int *X, int *Y){
    int minx=(1<<32)-1, miny=(1<<32)-1;
    for (int a=0; a<N; a++) {
        minx = min(minx, X[a]);
        miny = min(miny, Y[a]);
    }
    sort(X, X+N);
    sort(Y, Y+N);
    long long bx=0, by=0;
    for (int a=0; a<N; a++) {
        bx+=(X[a]-X[0]);
        by+=(Y[a]-Y[0]);
    }
    long long ans=(bx+by)%1000000000;
    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:5:16: warning: left shift count >= width of type [-Wshift-count-overflow]
    5 |     int minx=(1<<32)-1, miny=(1<<32)-1;
      |               ~^~~~
city.cpp:5:32: warning: left shift count >= width of type [-Wshift-count-overflow]
    5 |     int minx=(1<<32)-1, miny=(1<<32)-1;
      |                               ~^~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 604 KB Output is correct
2 Correct 5 ms 648 KB Output is correct
3 Correct 10 ms 860 KB Output is correct
4 Correct 10 ms 856 KB Output is correct
5 Correct 20 ms 1524 KB Output is correct
6 Correct 22 ms 1112 KB Output is correct
7 Correct 21 ms 1112 KB Output is correct
8 Correct 19 ms 1116 KB Output is correct
9 Correct 26 ms 1372 KB Output is correct
10 Correct 20 ms 1116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -