# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
321683 | daniel920712 | Soccer (JOI17_soccer) | C++14 | 2 ms | 492 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 <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <set>
#include <map>
#include <algorithm>
#include <time.h>
#include <algorithm>
#include <queue>
#include <utility>
#include <map>
using namespace std;
long long x[1000005];
long long y[1000005];
map < pair < long long , pair < long long ,long long > > , long long > DP;
long long N,A,B,C;
long long F(long long here,long long xx,long long yy)
{
if(here==N) return 0;
if(DP.find(make_pair(here,make_pair(xx,yy)))!=DP.end()) return DP[make_pair(here,make_pair(xx,yy))];
DP[make_pair(here,make_pair(xx,yy))]=(abs(xx-x[here])+abs(yy-y[here]))*C+min(min(C*abs(xx-x[here+1]) ,(xx!=x[here+1])*B)+F(here+1,x[here+1],yy),min(C*abs(yy-y[here+1]),(yy!=y[here+1])*B)+F(here+1,xx,y[here+1]));
return DP[make_pair(here,make_pair(xx,yy))];
}
int main()
{
long long H,W;
long long i;
scanf("%lld %lld",&H,&W);
scanf("%lld %lld %lld",&A,&B,&C);
scanf("%lld",&N);
for(i=0;i<N;i++) scanf("%lld %lld",&x[i],&y[i]);
if(N==2) printf("%lld\n",min(C*abs(y[1]-y[0])+min(C*abs(x[1]-x[0]),A*abs(x[1]-x[0])+B),C*abs(x[1]-x[0])+min(C*abs(y[1]-y[0]),A*abs(y[1]-y[0])+B)));
else
{
printf("%lld\n",F(0,x[0],y[0]));
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |