This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <traffic.h>
#include <bits/stdc++.h>
using namespace std;
int LocateCentre(int N, int P[], int S[], int D[]){
vector<long long> V;
vector<long long> V1;
V.push_back(P[0]);
V1.push_back(P[0]);
for(int i=1;i<N;i++){
V.push_back(P[i-1]+P[i]);
V1.push_back(P[i]);
}
long long minmax=10000000000;
long long res;
for(int i=0;i<N;i++){
long long a=V[V.size()-1]-V[i];
long long b=V[i-1];
long long c=max(a,b);
if(c<minmax){
minmax=c;
res=i;
}
}
return res+1;
}
/*int main(){
long long N=5;
int P[]={1,2,3,4,5};
int S[]={1,2,3,4,5};
int D[]={1,2,3,4,5};
long long res=LocateCentre(N,P,S,D);
cout<<res;
}*/
Compilation message (stderr)
traffic.cpp: In function 'int LocateCentre(int, int*, int*, int*)':
traffic.cpp:24:15: warning: 'res' may be used uninitialized in this function [-Wmaybe-uninitialized]
24 | return res+1;
| ~~~^~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |