# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
477284 | Tsiannis | Traffic (IOI10_traffic) | C++17 | 0 ms | 0 KiB |
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<bits/stdc++.h>
using namespace std;
#define INF 100000000000
typedef long long ll;
int main()
{
ll N;
cin>>N;
ll sum=0;
ll P[N],D[N],S[N],pre[N];
for (int i=0;i<N;i++)
{
cin>>P[i];
sum+=P[i];
pre[i]=sum;
}
for (int i=0;i<N-1;i++)
{
cin>>S[i]>>D[i];
}
ll mn=INF;
ll index;
ll d=sum/2;
for (int i=0;i<N;i++)
{
ll d=(sum-P[i])/2;
if (abs(pre[i]-d-P[i])<mn)
{
mn=abs(pre[i]-d-P[i]);
index=i;
}
}
cout<<index<<endl;
return 0;
}