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 <vector>
#include <map>
#include <iostream>
using namespace std;
int const N=1010,M=1010;
long long reach[N][M]={};
int n,m;
long long st[N],sp[N];
int stops[N];
void init(int L, int N, vector<long long> T, vector<int> W, int X, int M, vector<int> S)
{
n=N,m=M;
for (int i=0;i<n;i++)
st[i]=T[i];
for (int i=0;i<n;i++)
sp[i]=W[i];
for (int i=0;i<m;i++)
stops[i]=S[i];
sp[n]=X;
}
void comp()
{
map<long long,vector<int>>d;
for (int i=0;i<=n;i++)
{
reach[i][0]=st[i];
d[st[i]].push_back(i);
}
for (int i=1;i<m;i++)
{
long long pre=0;
for (auto j:d)
{
long long mn=0;
for (auto k:j.second)
{
reach[k][i]=reach[k][i-1]+sp[k]*(stops[i]-stops[i-1]);
reach[k][i]=max(pre,reach[k][i]);
mn=max(mn,reach[k][i]);
}
pre=max(pre,mn);
}
d.clear();
for (int j=0;j<=n;j++)
d[reach[j][i]].push_back(j);
}
}
long long arrival_time(long long Y)
{
st[n]=Y;
comp();
return reach[n][m-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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |