标签:for ace 贪心 .com span ifd 题解 rest contest
【链接】 我是链接,点我呀:)
【题意】
在这里输入题意
【题解】
贪心选容量大的瓶子就好
【代码】
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1e5;
int n;
int a[N+10],b[N+10];
main(){
#ifdef LOCAL_DEFINE
freopen("F:\\c++source\\rush_in.txt", "r", stdin);
#endif
ios::sync_with_stdio(0),cin.tie(0);
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+1+n);
int rest = b[n] + b[n-1];
for (int i = 1;i <= n;i++){
if (rest>=a[i]){
rest-=a[i];
}else return cout << "NO"<<endl,0;
}
cout << "YES"<<endl;
return 0;
}
【Codeforces Round #446 (Div. 2) A】Greed
标签:for ace 贪心 .com span ifd 题解 rest contest
原文地址:http://www.cnblogs.com/AWCXV/p/7855796.html