Submission #737763

# Submission time Handle Problem Language Result Execution time Memory
737763 2023-05-07T17:13:19 Z 1075508020060209tc Soccer (JOI17_soccer) C++14
5 / 100
1 ms 212 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define X first
#define Y second
int H;int W;
int A;int B;int C;
int n;

pair<int,int>ar[200005];

int kick(int x,int y){
return B+A*abs(x-y);
}
int walk(int x,int y){
return C*abs(x-y);
}
signed main(){
cin>>H>>W;
cin>>A>>B>>C;
cin>>n;
for(int i=1;i<=n;i++){
    cin>>ar[i].first>>ar[i].second;
}
int ans;
if(ar[1].first==ar[n].first){
    ans=B+A*abs(ar[1].second-ar[n].second);
    ans=min(ans,C*abs(ar[1].second-ar[n].second));
    cout<<ans<<endl;return 0;
}
if(ar[1].second==ar[n].second){
    ans=B+A*abs(ar[1].first-ar[n].first);
    ans=min(ans,C*abs(ar[1].first-ar[n].first));
    cout<<ans<<endl;return 0;
}


ans=1e18;
ans=min(ans,kick(ar[1].X,ar[n].X)+walk(ar[1].Y,ar[n].Y)*2ll);
ans=min(ans,kick(ar[1].X,ar[n].X)+walk(ar[1].Y,ar[n].Y)+kick(ar[1].Y,ar[n].Y));
ans=min(ans,walk(ar[1].X,ar[n].X)+walk(ar[1].Y,ar[n].Y));
ans=min(ans,walk(ar[1].X,ar[n].X)+kick(ar[1].Y,ar[n].Y));
swap(ar[1].first,ar[1].second);
swap(ar[2].first,ar[2].second);
ans=min(ans,kick(ar[1].X,ar[n].X)+walk(ar[1].Y,ar[n].Y)*2ll);
ans=min(ans,kick(ar[1].X,ar[n].X)+walk(ar[1].Y,ar[n].Y)+kick(ar[1].Y,ar[n].Y));
ans=min(ans,walk(ar[1].X,ar[n].X)+walk(ar[1].Y,ar[n].Y));
ans=min(ans,walk(ar[1].X,ar[n].X)+kick(ar[1].Y,ar[n].Y));


cout<<ans<<endl;



}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Incorrect 0 ms 212 KB Output isn't correct
7 Halted 0 ms 0 KB -