Submission #1608658


Source Code Expand

#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <set>
#include <string>
#include <vector>
#include <array>
#include <stdlib.h>

#define INT_MAX 2000000000
#define MOD 1000000007
#define ll long long
#define REP(i,a,b) for(i = (a); i < (b); i++)
#define rep(i,n) REP(i,0,n)
#define bitget(a,b) (((a) >> (b)) & 1)

using namespace std;

int i, j, k;

int main() {
	int n;
	int a[100000];
	cin >> n;
	rep(i, n) {
		cin >> a[i];
	}
	sort(a,a+n);
	ll int d = 1;
	ll int ans1 = 0, ans2 = 0;
	for (i = n - 2; i > -1; i--) {
		if (a[i] == a[i + 1]) {
			d++;
		}
		else {
			d = 1;
		}
		if (d == 2) {
			if (ans1 == 0) {
				ans1 = a[i];
				d = 0;
			}
			else {
				ans2 = a[i];
				d = -1;
			}
		}
		if (d == -1) {
			break;
		}
	}
	cout << ans1*ans2 << endl;

	return 0;
}

Submission Info

Submission Time
Task C - Make a Rectangle
User noshi91
Language C++14 (GCC 5.4.1)
Score 300
Code Size 863 Byte
Status AC
Exec Time 60 ms
Memory 640 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 15
Set Name Test Cases
Sample sample1.txt, sample2.txt, sample3.txt
All sample1.txt, sample2.txt, sample3.txt, 1.txt, 2.txt, 3.txt, 4.txt, 5.txt, 6.txt, 7.txt, 8.txt, 9.txt, sample1.txt, sample2.txt, sample3.txt
Case Name Status Exec Time Memory
1.txt AC 59 ms 640 KB
2.txt AC 29 ms 384 KB
3.txt AC 60 ms 640 KB
4.txt AC 59 ms 640 KB
5.txt AC 29 ms 384 KB
6.txt AC 57 ms 640 KB
7.txt AC 56 ms 640 KB
8.txt AC 24 ms 384 KB
9.txt AC 30 ms 384 KB
sample1.txt AC 1 ms 256 KB
sample2.txt AC 1 ms 256 KB
sample3.txt AC 1 ms 256 KB