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;
typedef long long ll;
typedef pair<int, int> pi;
#define mp make_pair
#define f first
#define s second
int H, W;
ll A, B, C;
const int mx = 100005;
int N;
pi ST[mx];
ll KICK(pi a, pi b){
int xdist = abs(a.f-b.f);
int ydist = abs(a.s-b.s);
return min(C*(xdist+ydist), B+A*(max(xdist, ydist))+C*(min(xdist, ydist)));
}
int main(){
cin >> H >> W;
cin >> A >> B >> C;
cin >> N;
for(int i = 1; i <= N; i++){
cin >> ST[i].f >> ST[i].s;
}
if(N == 2){
ll ans = KICK(ST[1], ST[2]);
cout << ans << "\n";
exit(0);
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |