-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcf_1427_a.py
75 lines (72 loc) · 1.54 KB
/
cf_1427_a.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# t = int(input())
# for i in range(t):
# n = int(input())
# a = list(map(int, input().split()))[:n]
# s = 0
# b = []
# b.append(a[0])
# for i in range(2,n):
# s = sum(b)
#
# if s+a[i-1]!=0:
# b.append(a[i-1])
# a.remove(a[i-1])
# else:
# if sum(a)!=0:
# a.append(a[i-1])
#
#
# print(*a, sep=" ")
# print("----------")
# print(b)
# print("----------")
#
#
#
# # t = int(input())
# # for i in range(t):
# # n = int(input())
# # a = list(map(int, input().split()))[:n]
# # b= []
# #
# # i = 2
# # c = []
# # b.append(a[0])
# # while(i<=n):
# # x = sum(b)
# # ns = x + a[i-1]
# # if x != 0 and ns != 0:
# # b.append(a[i - 1])
# # else:
# # c.append(a[i-1])
# # i += 1
# # j = 1
# # while (len(c)!=0 and sum(c)!= 0):
# # fc = sum(b)
# # if c[j-1]+fc != 0:
# # b.append(c[j-1])
# # c.remove(c[j-1])
# # else:
# # c.append(c[j-1])
# #
# # if sum(b) == 0:
# # print("NO")
# # else:
# # print("YES")
# # print(*b, sep=" ")
# #
t = int(input())
for i in range(t):
n = int(input())
a = list(map(int, input().split()))[:n]
if sum(a)==0:
print("NO")
else:
if sum(a)>0:
a.sort(reverse=True)
print("YES")
print(*a,sep=" ")
else:
a.sort()
print("YES")
print(*a, sep=" ")