比赛 果蝇王邀请赛div2 评测结果 AAAAAWWWWWWWWWWWWWWWAWWWWWAWWWWWWWW
题目名称 雪王与果蝇王游于濠梁之上 最终得分 5
用户昵称 赵飞羽 运行时间 0.253 s
代码语言 C++ 内存使用 3.92 MiB
提交时间 2026-08-27 11:20:48
显示代码纯文本
#include <bits/stdc++.h>
#define int long long
using namespace std;

constexpr int N = 100010;
int h, w, a, b, c, n, s[N], t[N], ans = 9e18;

signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	freopen("play.in", "r", stdin);
	freopen("play.out", "w", stdout);
	cin >> h >> w >> a >> b >> c >> n;
	for (int i = 1; i <= n; i++) cin >> s[i] >> t[i];
	if (n == 2) {
		ans = min(ans, c * abs(s[1] - s[2]) + c * abs(t[1] - t[2]));
		ans = min(ans, a * abs(s[1] - s[2]) + b + c * abs(t[1] - t[2]));
		ans = min(ans, c * abs(s[1] - s[2]) + a * abs(t[1] - t[2]) + b);
	} else ans = c * abs(s[1] - s[n]) + c * abs(t[1] - t[n]);
	cout << ans;
	return 0;
}