(AGC)C - Make a Rectangle

C - Make a Rectangle


Time limit : 2sec / Memory limit : 256MB

Score : 300 points

Problem Statement

We have N sticks with negligible thickness. The length of the i-th stick is Ai.

Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides. Find the maximum possible area of the rectangle.

Constraints

  • 4N105
  • 1Ai109
  • Ai is an integer.

Input

Input is given from Standard Input in the following format:

N
A1 A2 ... AN

Output

Print the maximum possible area of the rectangle. If no rectangle can be formed, print 0.


Sample Input 1

Copy
6
3 1 2 4 2 1

Sample Output 1

Copy
2

1×2 rectangle can be formed.


Sample Input 2

Copy
4
1 2 3 4

Sample Output 2

Copy
0

No rectangle can be formed.


Sample Input 3

Copy
10
3 3 3 3 4 4 4 5 5 5

Sample Output 3

Copy
20
 
    
#include
#include
#include
using namespace std;
typedef long long ll;
const int maxn=1e5+10;
struct node{
	int id;
	int nu;
}b[maxn];
int n;
int a[maxn];
int main()
{
	int i,j;
	while(scanf("%d",&n)!=EOF)
	{
		for(i=0;i=0)
		{
			num++;
			for(j=i;j>=0;j--)
			{
				if(a[j]!=a[i])
					break;
				else cnt++;
			}
			b[num].id=a[i];
			b[num].nu=cnt;
			cnt=0;
			i=j;
		}
		int c[2];
		int s=0;
		c[0]=-1;
		c[1]=-1;
	//	for(i=1;i<=num;i++)
		//	cout<=4)
			{
				
				c[s]=b[i].id;
				s++;
				if(s>=2) break;
				c[s]=b[i].id;
				break;
			}
			if(b[i].nu>=2)
			{
			//	cout<<"!"<=2) break;
		}
		//cout<


你可能感兴趣的:((AGC)C - Make a Rectangle)