Submission #869389

# Submission time Handle Problem Language Result Execution time Memory
869389 2023-11-04T09:04:01 Z shdfshdfshdf Ideal city (IOI12_city) C++17
23 / 100
23 ms 1116 KB
#include <bits/stdc++.h>
using namespace std;

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);
    long long int bx=0, by=0;
    for (int a=0; a<n; a++) {
        bx+=x[a]-x[0];
        by+=y[a]-y[0];
    }
    long long int 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;
}
# 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 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 612 KB Output is correct
2 Correct 5 ms 604 KB Output is correct
3 Correct 13 ms 788 KB Output is correct
4 Correct 10 ms 856 KB Output is correct
5 Correct 20 ms 1112 KB Output is correct
6 Correct 20 ms 1116 KB Output is correct
7 Correct 23 ms 1116 KB Output is correct
8 Correct 20 ms 1116 KB Output is correct
9 Correct 21 ms 1116 KB Output is correct
10 Correct 20 ms 1116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -