-
Notifications
You must be signed in to change notification settings - Fork 0
/
DHRECT.cpp
36 lines (34 loc) · 903 Bytes
/
DHRECT.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
#include <bits/stdc++.h>
using namespace std;
#define fr(i,l,r) for(int i=l;i<=r;++i)
#define fd(i,r,l) for(int i=r;i>=l;--i)
typedef long long int lli;
priority_queue<lli, vector<lli>, less<lli> > diem, rect;
lli value,temp = -1,n,k,recent;
int main() {
cin >> k;
while(k--) {
cin >> n;
fr(i,1,n) {
cin >> value;
diem.push(value);
}
while (!diem.empty()) {
if(diem.top() == temp ) {
rect.push(diem.top());
temp = -1;
}
else temp = diem.top();
diem.pop();
}
if(rect.size() < 2) cout << -1;
else {
temp = rect.top();
rect.pop();
cout << temp*rect.top();
}
while(!rect.empty()) rect.pop();
cout << endl;
temp = -1;
}
}