144842025-01-11 21:40:12ubormaciLegnagyobb téglalapcpp17Accepted 100/100108ms7336 KiB
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstdint>
using namespace std;
typedef int64_t ll;

int main() {
    ll n;
    cin >> n;
    map<ll,ll> mp;
    for(ll i = 0; i < n; i++) {
        ll tmp;
        cin >> tmp;
        mp[tmp]++;
    }

    /*
    for(const auto & x : mp) {
        cerr << "\nmp " << x.first << " = " << x.second; 
    }
    */

    ll a = 0, b = 0;
    for(auto it = mp.rbegin(); it != mp.rend(); it++) {
        auto x = *it;
        //cerr << "\nx=" << x.first;
        if(x.second < 2) {
            //cerr << "\nskipped";
            continue;
        }
        if(x.second >= 2 && x.second < 4) {
            if(a == 0) {
                a = x.first;
            }else{
                b = x.first;
                break;
            }
        }
        if(x.second >= 4) {
            if(a == 0) {
                a = x.first;
                b = x.first;
            }else{
                b = x.first;
            }
            break;
        }
    }
    cout << a * b;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted1ms316 KiB
2Accepted1ms508 KiB
3Accepted1ms316 KiB
subtask210/10
4Accepted1ms316 KiB
5Accepted1ms316 KiB
6Accepted1ms316 KiB
7Accepted1ms316 KiB
8Accepted1ms316 KiB
subtask310/10
9Accepted1ms320 KiB
10Accepted1ms316 KiB
11Accepted1ms316 KiB
12Accepted1ms400 KiB
13Accepted17ms596 KiB
14Accepted17ms596 KiB
subtask415/15
15Accepted1ms316 KiB
16Accepted1ms316 KiB
17Accepted1ms512 KiB
18Accepted1ms512 KiB
19Accepted1ms404 KiB
20Accepted1ms316 KiB
21Accepted1ms316 KiB
22Accepted1ms316 KiB
23Accepted1ms316 KiB
24Accepted1ms316 KiB
subtask520/20
25Accepted2ms316 KiB
26Accepted4ms632 KiB
27Accepted4ms740 KiB
28Accepted4ms576 KiB
29Accepted4ms668 KiB
30Accepted4ms564 KiB
31Accepted4ms564 KiB
32Accepted3ms412 KiB
subtask615/15
33Accepted1ms316 KiB
34Accepted65ms5220 KiB
35Accepted75ms7172 KiB
36Accepted79ms7216 KiB
37Accepted74ms7160 KiB
38Accepted71ms7216 KiB
39Accepted72ms7272 KiB
40Accepted4ms316 KiB
41Accepted48ms1960 KiB
subtask730/30
42Accepted41ms944 KiB
43Accepted86ms7032 KiB
44Accepted93ms7220 KiB
45Accepted103ms7336 KiB
46Accepted108ms7112 KiB
47Accepted87ms7176 KiB
48Accepted104ms7220 KiB
49Accepted92ms7220 KiB
50Accepted54ms2112 KiB
51Accepted59ms2636 KiB