#include <bits/stdc++.h>
#define IO_OP ios::sync_with_stdio(0), cin.tie(0)
#define F first
#define S second
#define V vector
#define PB push_back
#define EB emaplce_back
#define MP make_pair
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
const int INF = 1e9 + 7;
const ll oo = 1e18;
signed main()
{
IO_OP;
int h, w, a, b, c, n;
cin >> h >> w >> a >> b >> c >> n;
vi s(n), t(n);
for(int i = 0; i < n; i++)
cin >> s[i] >> t[i];
ll ans = oo;
ans = min(ans, 1LL * (abs(s[0] - s[1]) + 1LL * abs(t[0] - t[1])) * c);
ans = min(ans, 1LL * (abs(t[0] - t[1])) * a + b + 1LL * abs(s[0] - s[1]) * c);
ans = min(ans, 1LL * (abs(s[0] - s[1])) * a + b + 1LL * abs(t[0] - t[1]) * c);
cout << ans << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
0 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
0 ms |
208 KB |
Output is correct |
6 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |