-
Notifications
You must be signed in to change notification settings - Fork 0
/
extra1.cpp
139 lines (102 loc) · 2.44 KB
/
extra1.cpp
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#include<bits/stdc++.h>
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define F(i,a,n) for(ll i=a;i<n;i++)
#define B(i,a,n) for(ll i=n-1;i>=a;i--)
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define ps(x,y) fixed<<setprecision(y)<<x
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define vll vector<ll>
ll mod = 1e9 + 7;
using namespace std;
/* inline bool isPalindrome(const string& s) {
return equal(s.begin(), s.end(), s.rbegin());
}*/
bool cmp(ll a, ll b)
{
return a < b;
}
template<typename T>
bool allEqual(std::vector<T> const &v) {
if (v.size() == 0) {
return false;
}
return std::equal(v.begin() + 1, v.end(), v.begin());
}
ll num_uniq(vector<ll> v)
{
sort(all(v));
return distance(v.begin(),unique(v.begin(), v.end()));
}
// xor of a number x with a number with all 1's gives the number with every bit of x flipped.
ll bit_all_1 = 4294967295;
// Very large power very large number modulo...
ll long_power_long(ll x, ll n)
{
ll result = 1;
while (n) {
if (n & 1)
result = result * x % mod;
n = n / 2;
x = x * x % mod;
}
return result;
}
ll lcm(ll a, ll b)
{
return (a*b)/__gcd(a,b);
}
// TO REMOVE ALL NUMS ALSO THEN USE "isalpha" instead of "isalnum".
// To apply this -> str.erase(it,str.end());
/*
auto it = std::remove_if(str.begin(), str.end(), [](char const &c) {
return !std::isalnum(c);
});
*/
// std::rotate(nums.begin(),nums.begin() + n-(k%n), nums.end()); to rotate vector to right k steps.
// if we want an element at index 'Z' to become 1st element after rotations we replace n-(k&n) with z;
void pairsort(vll &a, vll &b, ll n)
{
vector<pair<ll,ll>> v(n);
for(int i=0;i<n;i++)
{
v[i] = {a[i],b[i]};
}
sort(all(v));
for(int i=0;i<n;i++)
{
a[i] = v[i].first;
b[i] = v[i].second;
}
}
int main()
{
// your code goes here.
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
ll t;
cin >> t;
while(t--)
{
priority_queue<ll> pq;
ll n,k;
cin >> n;
for(ll i=0;i<n;i++)
{
cin >> k;
pq.push(k);
}
// sort();
for(ll i=0;i<n;i++)
{
cout << pq.top() << " ";
pq.pop();
}
cout << endl;
}
return 0;
}