Submission #3913253


Source Code Expand

Copy
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    // input
    ll N;
    cin >> N;

    map<ll, ll> mp;
    FOR(i, 0, N){
        ll a;
        cin >> a;
        mp[a]++;
    }

    vector<ll> candidates;
    for(auto a : mp){
        ll length = a.first;
        ll count = a.second;
        if(count >= 2){
            candidates.push_back(length);
        }
    }
    sort(ALL(candidates));

    if(candidates.size()==0){
        p(0);
    }
    else if(candidates.size()==1){
        ll length = candidates[0];
        ll count = mp[length];
        if(count < 4){
            p(0);
        }else{
            p(length * length);
        }
    }
    else{
        ll L = candidates.size();
        ll longest = candidates[L-1];
        ll count = mp[longest];
        if(count > 3){
            p(longest * longest);
        }else{
            p(longest * candidates[L-2]);
        }
    }
    
    return 0;
}

Submission Info

Submission Time
Task C - Make a Rectangle
User peroon
Language C++14 (GCC 5.4.1)
Score 300
Code Size 1538 Byte
Status
Exec Time 46 ms
Memory 6528 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample1.txt, sample2.txt, sample3.txt
All 300 / 300 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 41 ms 4988 KB
2.txt 7 ms 256 KB
3.txt 46 ms 6528 KB
4.txt 35 ms 3452 KB
5.txt 7 ms 256 KB
6.txt 13 ms 256 KB
7.txt 12 ms 256 KB
8.txt 6 ms 256 KB
9.txt 22 ms 3456 KB
sample1.txt 1 ms 256 KB
sample2.txt 1 ms 256 KB
sample3.txt 1 ms 256 KB