A38502 题解
2026-10-06 18:35:59
发布于:浙江
0阅读
0回复
0点赞
#include <bits/stdc++.h>
using namespace std;
int a[10005],b[10005];int n;
int main(){
cin >> n;
for(int i = 1;i <= n;i++)cin >> a[i];
for(int i = 1;i <= n;i++)cin >> b[i];
sort(b+1,b+n+1);
for(int i = 1;i <= n;i++){
bool vi = 0;
int need = a[i+1] - a[i];
for(int j = 1;j <= n;j++){
if(b[j] >= need){
b[j] = 0;
vi = 1;
break;
}
}if(!vi){
cout << "NO" << endl << i;
return 0;
}
}cout << "YES";
return 0;
}
这里空空如也






有帮助,赞一个