1 条题解
-
0
#include <iostream> #include <algorithm> using namespace std; struct Cut { int cost; int type; } p[4005]; bool cmp(const Cut &x, const Cut &y) { return x.cost > y.cost; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N, M; cin >> N >> M; int tot = 0; for (int i = 0; i < N - 1; ++i) { cin >> p[tot].cost; p[tot].type = 0; tot++; } for (int i = 0; i < M - 1; ++i) { cin >> p[tot].cost; p[tot].type = 1; tot++; } sort(p, p + tot, cmp); long long ans = 0; int cntH = 1; int cntV = 1; for (int i = 0; i < tot; ++i) { if (p[i].type == 0) { ans += 1LL * p[i].cost * cntV; cntH++; } else { ans += 1LL * p[i].cost * cntH; cntV++; } } cout << ans << endl; return 0; }
- 1
信息
- ID
- 5442
- 时间
- 1000ms
- 内存
- 125MiB
- 难度
- 5
- 标签
- 递交数
- 6
- 已通过
- 3
- 上传者