Submission #1525576
Source Code Expand
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i=a; i<b; i++)
using namespace std;
typedef long long ll;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
map<ll, int> m;
int n;
cin >> n;
rep(i, 0, n){
ll a;
cin >> a;
m[a]++;
}
ll sq = -1;
vector<ll> v;
for(auto p: m){
if( p.second >= 2 )
v.push_back(p.first);
if( p.second >= 4 )
sq = max(sq, p.first);
}
if( v.size() < 2 ){ // No rectangle possible
if( sq != -1 ) // But square possible
cout << sq*sq << endl;
else
cout << 0 << endl;
}else{
n = v.size();
ll reca = v[n-1]*v[n-2];
if( reca > sq*sq )
cout << reca << endl;
else
cout << sq*sq << endl;
}
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - Make a Rectangle |
| User | blackarrow |
| Language | C++14 (GCC 5.4.1) |
| Score | 300 |
| Code Size | 816 Byte |
| Status | AC |
| Exec Time | 48 ms |
| Memory | 6528 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 300 / 300 | ||||
| Status |
|
|
| 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 | 42 ms | 4988 KiB |
| 2.txt | AC | 7 ms | 256 KiB |
| 3.txt | AC | 48 ms | 6528 KiB |
| 4.txt | AC | 36 ms | 3452 KiB |
| 5.txt | AC | 7 ms | 256 KiB |
| 6.txt | AC | 13 ms | 256 KiB |
| 7.txt | AC | 12 ms | 256 KiB |
| 8.txt | AC | 6 ms | 256 KiB |
| 9.txt | AC | 22 ms | 3456 KiB |
| sample1.txt | AC | 1 ms | 256 KiB |
| sample2.txt | AC | 1 ms | 256 KiB |
| sample3.txt | AC | 1 ms | 256 KiB |