#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int d[100010],lo[100010];
bool cmp(int a,int b){
return d[a]<d[b];
}
int main(){
int n;
while(scanf("%d",&n) == 1){
long long sum=0;
for(int i=0;i<n;i++){
scanf("%d",&d[i]);
sum+=d[i];
lo[i]=i;
}
sort(lo,lo+n);
if(sum&1){
printf("No\n");
continue;
}
sum/=2;
for(int i=n-1;i>=0;i--){
if(d[lo[i]]<=sum){
sum-=d[lo[i]];
d[lo[i]]=1;
}else d[lo[i]]=-1;
}
printf("Yes\n%d",d[0]);
for(int i=1;i<n;i++) printf(" %d",d[i]);
printf("\n");
}
}
uva 1614 贪心
最新推荐文章于 2021-05-08 22:50:11 发布