| 比赛 |
2025.12.6 |
评测结果 |
AAAAAAAAAA |
| 题目名称 |
巧克力 |
最终得分 |
100 |
| 用户昵称 |
彭欣越 |
运行时间 |
0.040 s |
| 代码语言 |
C++ |
内存使用 |
3.77 MiB |
| 提交时间 |
2025-12-06 09:53:35 |
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=10010;
ll n,m,a[N],b[N],ans;
struct node {
ll w,id;
bool operator<(const node&o) const{
return o.w>w;
}
};
priority_queue<node>q;
int main() {
freopen("chocolate.in","r",stdin);
freopen("chocolate.out","w",stdout);
ios::sync_with_stdio(0);
cin.tie(0),cout.tie(0);
cin >> n >> m;
for (int i=1;i<n;i++) {
cin >> a[i];
//ans+=a[i];
q.push({a[i],0});
}
for (int i=1;i<m;i++) {
cin >> b[i];
//ans+=b[i];
q.push({b[i],1});
}
int x=0,y=0;
while (!q.empty()) {
ll w=q.top().w,id=q.top().id;
q.pop();
if (!id) {
x++;
ans+=(y+1)*w;
}else{
y++;
ans+=(x+1)*w;
}
}
cout << ans <<endl;
return 0;
}