122122024-12-09 13:29:14CsongiLegnagyobb téglalapcpp17Wrong answer 0/10059ms5108 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n; cin >> n;
    map<int, int> m;
    vector<int> v(0);
    for (int i = 0; i < n; i++)
    {
        int be; cin >> be;
        m[be]++;
    }
    for (auto it = m.begin(); it != m.end(); ) {
        if (it->second < 2) {
            it = m.erase(it);
        } else {
            v.push_back(it->first);
            ++it;
        }
    }
    sort(v.begin(), v.end());
    if (v.size() > 0 && m[v.size()-1] > 3)
    {
        cout << v[v.size()-1] * v[v.size()-1] << endl;
    }
    else
    {
        if (v.size() > 1)
        {
            cout << v[v.size()-1] * v[v.size()-2] << endl;
        }
        else
        {
            cout << "0" << endl;
        }
    } 
    return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted1ms508 KiB
2Accepted1ms320 KiB
3Wrong answer1ms320 KiB
subtask20/10
4Wrong answer1ms320 KiB
5Accepted1ms320 KiB
6Accepted1ms320 KiB
7Accepted1ms320 KiB
8Accepted1ms320 KiB
subtask30/10
9Wrong answer1ms320 KiB
10Wrong answer1ms320 KiB
11Wrong answer1ms320 KiB
12Wrong answer1ms320 KiB
13Wrong answer8ms432 KiB
14Accepted8ms432 KiB
subtask40/15
15Accepted1ms320 KiB
16Accepted1ms320 KiB
17Accepted1ms320 KiB
18Accepted1ms508 KiB
19Accepted1ms320 KiB
20Wrong answer1ms320 KiB
21Accepted1ms352 KiB
22Accepted1ms320 KiB
23Wrong answer1ms320 KiB
24Accepted1ms320 KiB
subtask50/20
25Wrong answer1ms320 KiB
26Wrong answer3ms568 KiB
27Accepted3ms560 KiB
28Wrong answer3ms580 KiB
29Wrong answer3ms748 KiB
30Wrong answer3ms568 KiB
31Wrong answer3ms800 KiB
32Accepted2ms320 KiB
subtask60/15
33Accepted1ms320 KiB
34Wrong answer39ms3828 KiB
35Accepted41ms4924 KiB
36Wrong answer41ms4896 KiB
37Wrong answer41ms4868 KiB
38Wrong answer41ms5084 KiB
39Wrong answer43ms5108 KiB
40Wrong answer2ms320 KiB
41Accepted24ms1424 KiB
subtask70/30
42Accepted24ms760 KiB
43Wrong answer59ms4924 KiB
44Accepted57ms4944 KiB
45Wrong answer54ms5048 KiB
46Wrong answer57ms5104 KiB
47Wrong answer59ms4968 KiB
48Wrong answer57ms5088 KiB
49Accepted54ms4920 KiB
50Wrong answer34ms1488 KiB
51Wrong answer37ms1932 KiB