# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
332381 | lumen | 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>
#include<iomanip>
#include<cmath>
using namespace std;
typedef long long int lli;
#define PB push_back
#define MP make_pair
#define FR first
#define SR second
#define LB lower_bound
#define UB upper_bound
typedef vector<long long int> vi;
typedef pair<long long int,long long int> pi;
#define all(a) (a).begin(),(a).end()
#define allr(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=a;i<b;i++)
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
lli N;
cin>>N;
vi P(N+1);
vi S(N+1),D(N+1);
FOR(i,1,N+1)
{
cin>>P[i];
}
FOR(i,1,N)
{
cin>>S[i];
}
FOR(i,1,N)
{
cin>>D[i];
}
vi pre(N+1,0);
FOR(i,1,N+1)
{
pre[i]=pre[i-1]+P[i];
}
lli ans=INT_MAX;
lli index;
FOR(j,1,N+1)
{
lli point1=max(pre[j-1],pre[N]-pre[j]);
if(ans>point1)
{
ans=point1;
index=j-1;
}
}
cout<<index;
}