#include "traffic.h"
int LocateCentre(int N, int pp[], int S[], int D[]) {
long long pre[N];
pre[0] = pp[0];
for(int i=1; i<N; i++){
pre[i] = pre[i-1] + pp[i];
}
int sol = -1;
long long congestion = 1e18;
for(int i=0; i<N; i++){
long long mayor = (pre[i] - pp[i] > pre[N-1] - pre[i] ? pre[i] - pp[i] : pre[N-1] - pre[i]);
if(mayor < congestion){
mayor = congestion;
sol = i;
}
}
return sol;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |