#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mxn = 1e5+5;
int h, w, n;
ll A, B, C;
ll s[mxn], t[mxn];
int main(int argc, char const *argv[]) {
cin >> h >> w >> A >> B >> C;
cin >> n;
for(int i = 0; i < n; i++) cin >> s[i] >> t[i];
if(C <= A) {
cout << C*(labs(s[0]-s[n-1])+labs(t[0]-t[n-1])) << "\n";
return 0;
}
if(n == 2) {
cout << min(C*(labs(s[0]-s[n-1])+labs(t[0]-t[n-1])), C*min(labs(s[0]-s[n-1]), labs(t[0]-t[n-1]))+A*max(labs(s[0]-s[n-1]), labs(t[0]-t[n-1]))+B) << "\n";
}
else {
cout << "0\n";
}
return 0;
}
# |
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 |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
308 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 |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
308 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 |
- |