企业危机
2023-08-05 09:59:36
发布于:浙江
#include <bits/stdc++.h>
using namespace std; //template
int a[20010],n,m,sum;
map<int,short> b;
int maxa,maxb;
int main(){
cin >> n >> m;
for(int i = 1;i <= n;i++){
cin >> a[i];
maxa = max(a[i],maxa);
}
for(int i = 1;i <= m;i++){
int tmp;
cin >> tmp;
b[tmp]++;
maxb = max(tmp,maxb);
}
if(maxa > maxb || n > m){
cout << "you died!";
return 0;
}
for(int i = 1;i <= n;i++){
bool flag = 0;
for(int j = a[i];j <= maxb;j++){
int debug = b[j];
if(b[j] > 0){
flag = 1;
b[j]--;
sum += j;
break;
}
}
if(!flag){cout << "you died!";return 0;}
}
cout << sum;
return 0;
}
这里空空如也
有帮助,赞一个