Submission #2243468


Source Code Expand

#include <iostream>
#include <vector>
#include <unordered_map>
#include <algorithm>

using namespace std;
using ll = long long;

int main(){
    int N;
    cin >> N;
    vector<ll> A(N);
    unordered_map<ll,int> mp;

    for(int i=0;i<N;i++){
        cin >> A[i];
        mp[A[i]]++;
    }

    sort(A.begin(), A.end(), greater<int>());
    A.erase(unique(A.begin(), A.end()), A.end());

    int found = 0;
    ll ans = 1ll;
    for(auto itr = A.begin(); itr!=A.end(); ++itr){
        if(mp[*itr] >= 4){
            if(found == 0){
                ans = 1ll;
                ans *= *itr;
                ans *= *itr;
                found = 2;
                break;
            }else{
                ans *= *itr;
                found++;
            }
        }
        if(mp[*itr] == 2 || mp[*itr] == 3){
            found++;
            ans *= *itr;
        }

        if(found == 2){
            break;
        }
    }

    if(found < 2){
        cout << 0 << endl;
    }else{
        cout << ans << endl;
    }
    return 0;
}

Submission Info

Submission Time
Task C - Make a Rectangle
User okesaku
Language C++14 (GCC 5.4.1)
Score 300
Code Size 1086 Byte
Status AC
Exec Time 71 ms
Memory 5156 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 62 ms 4492 KB
2.txt AC 24 ms 640 KB
3.txt AC 71 ms 5156 KB
4.txt AC 57 ms 2828 KB
5.txt AC 24 ms 640 KB
6.txt AC 47 ms 1024 KB
7.txt AC 46 ms 1024 KB
8.txt AC 19 ms 512 KB
9.txt AC 35 ms 2700 KB
sample1.txt AC 1 ms 256 KB
sample2.txt AC 1 ms 256 KB
sample3.txt AC 1 ms 256 KB