## 1614 - Hell on the Markets

All about problems in Volume 16. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

12061160
New poster
Posts: 7
Joined: Mon Jul 21, 2014 10:38 am

### 1614 - Hell on the Markets

Code: Select all

``````#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <queue>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
#define RD(x) scanf("%d",&x)
#define RD2(x,y) scanf("%d%d",&x,&y)
#define clr0(x) memset(x,0,sizeof(x))
#define v first
#define pos second

typedef pair<int,int> p;
p s[100005];
bool ans[100005];
int n;

bool cmp(p a,p b)
{
return a.v > b.v;
}
int main() {
while(~RD(n)) {
int sum = 0;
clr0(ans);
for(int i = 0;i < n;++i){
RD(s[i].v);
s[i].pos = i;
sum += s[i].v;
}
if(sum&1)
puts("No");
else{
puts("Yes");
sum /= 2;
sort(s,s+n,cmp);
for(int i = 0;i < n;++i){
if(!sum)
break;
if(sum >= s[i].v)
sum -= s[i].v,ans[s[i].pos] = true;
}
for(int i = 0;i < n;++i){
if(ans[i])
printf("1 ");
else
printf("-1 ");
}
puts("");
}
}
}
``````
still get stuck...can anyone give me some help?

12061160
New poster
Posts: 7
Joined: Mon Jul 21, 2014 10:38 am

### Re: 1614-Hell on the Markets

got AC...
just change to long long type..