#include<bits/stdc++.h>
#define debug(x) cout << "\033[36m"<< __LINE__ << ":\033[39m " << (#x) << " = " << (x) << '\n'
#define F first
#define S second
const char nl = '\n';
using namespace std;
using ll = long long;
ll h, w;
ll A, B, C;
ll n;
vector<pair<ll, ll>> vp(100010);
ll dp[510][510];
ll dist(ll x, ll y, ll X, ll Y) {
return abs(x - X) + abs(y - Y);
}
ll shoot(ll x, ll y, ll X, ll Y) {
ll res1 = abs(x - X)*C;
ll res2 = abs(y - Y)*C;
res1 += A*dist(X, y, X, Y) + B;
res2 += A*dist(x, Y, X, Y) + B;
return min(res1, res2);
}
void solve() {
cin >> h >> w;
cin >> A >> B >> C;
cin >> n;
for (ll i = 1; i <= n; i ++) {
cin >> vp[i].F >> vp[i].S;
}
for (ll i = 0; i <= 500; i ++) {
for (ll j = 0; j <= 500; j ++) {
dp[i][j] = dist(vp[1].F, vp[1].S, i, j) * C;
}
}
cout << min(dp[vp[2].F][vp[2].S], shoot(vp[1].F, vp[1].F, vp[2].F, vp[2].S));
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
ll tst = 1;
// cin >> tst;
while (tst --) {
solve();
cout << nl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
4184 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
3932 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
4184 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |