#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using indexed_multiset = tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update>;
#define vi vector
#define int long long
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
const int inf = 1e18;
const int mod = 1e9+7;
const int maxn=2e5;
void solution(){
int h, w;
cin >> h >> w;
int a, b, c;
cin >> a >> b >> c;
int n;
cin >> n;
int x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
int mn=inf;
mn=min(mn, (abs(x1-x2)+abs(y1-y2))*c);
int diff=0;
for(int i=1; i<=max(abs(x1-x2), abs(y1-y2)); i++){
diff=max(diff, i*c-(a*i+b));
}
cout << mn-diff;
}
signed main(){
std::ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#ifdef khos
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int t=1;
// cin >> t;
while(t--){
solution();
cout << '\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... |