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>
#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]) + abs(t[0] - t[1])) * c);
ans = min(ans, 1LL * (abs(t[0] - t[1])) * a + b + abs(s[0] - s[1]) * c);
ans = min(ans, 1LL * (abs(s[0] - s[1])) * a + b + abs(t[0] - t[1]) * c);
cout << ans << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |