#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mp make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define allarr(a) a , a + n
#define ll long long
#define ull unsigned long long
#define pb push_back
#define fastio ios_base::sync_with_stdio(false) ; cin.tie(NULL); cout.tie(NULL)
#define sz(x) (int)x.size()
typedef pair<int, int> pi;
typedef pair<ll,ll> pll;
typedef pair<int,pi> trp ;
typedef vector<pi> vpi;
typedef vector<pll> vpll ;
// int ab (int x ) { return (x>0?x:-x); }
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const ll MOD = 1e9;
ll ser(int n){
ll x = 1LL*n ;
return ((x*(x+1))/2)%MOD;
}
int DistanceSum(int N, int *X, int *Y) {
sort(X,X+N);
sort(Y,Y+N);
int MinX= X[0];
int MinY = Y[0];
ll ans = 0 ;
for(int i = 0 ; i < N ; i++ ){
ans += ser(X[i]-X[0]);
ans %= MOD ;
}
for(int i = 0 ; i < N ; i++ ){
ans += ser(Y[i]-Y[0]);
ans %= MOD ;
}
return ((int)ans);
}
// #define inbuf_len 1 << 16
// #define outbuf_len 1 << 16
// int DistanceSum(int N, int *X, int *Y);
// int main() {
// int tmp;
// /* Set input and output buffering */
// char *inbuf, *outbuf;
// inbuf = (char*) malloc(inbuf_len * sizeof(char));
// outbuf = (char*) malloc(outbuf_len * sizeof(char));
// tmp = setvbuf(stdin, inbuf, _IOFBF, inbuf_len);
// assert(tmp == 0);
// tmp = setvbuf(stdout, outbuf, _IOFBF, outbuf_len);
// assert(tmp == 0);
// int N, i;
// tmp = scanf("%d", &N);
// assert(tmp == 1);
// int *sq_x, *sq_y;
// sq_x = (int*) malloc(N * sizeof(int));
// sq_y = (int*) malloc(N * sizeof(int));
// for (i = 0; i < N; i++) {
// tmp = scanf("%d %d", &sq_x[i], &sq_y[i]);
// assert(tmp == 2);
// }
// int ds = DistanceSum(N, sq_x, sq_y);
// printf("%d\n", ds);
// return 0;
// }
Compilation message
city.cpp: In function 'int DistanceSum(int, int*, int*)':
city.cpp:37:6: warning: unused variable 'MinX' [-Wunused-variable]
37 | int MinX= X[0];
| ^~~~
city.cpp:38:6: warning: unused variable 'MinY' [-Wunused-variable]
38 | int MinY = Y[0];
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
640 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
640 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |