Submission #109503

#TimeUsernameProblemLanguageResultExecution timeMemory
109503pamajIdeal city (IOI12_city)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; int prefx[maxn], prefy[maxn]; int DistanceSum(int N, int *X, int *Y) { sort(X, X + N); sort(Y, Y + N); for(int i = 0; i < N; i++) { if(!i) prefx[i] = X[i], prefy[i] = Y[i]; else prefx[i] = X[i] + prefx[i - 1], prefy[i] = Y[i] + prefy[i - 1]; } int sum = 0; for(int i = 0; i < n - 1; i++) { sum += prefx[n] - prefx[i] - (n - i)*X[i]; sum += prefy[n] - prefy[i] - (n - i)*Y[i]; } return sum; }

Compilation message (stderr)

city.cpp: In function 'int DistanceSum(int, int*, int*)':
city.cpp:21:21: error: 'n' was not declared in this scope
  for(int i = 0; i < n - 1; i++)
                     ^