Submission #3187874


Source Code Expand

#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define vii vector<int>
#define vll vector<long long>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n;
    map<ll, ll> a;
    rep(i, 0, n) {
        ll p; cin >> p;
        a[p]++;
    }
    ll use = 0, ans = 0;
    for (auto itr = a.begin(); itr != a.end(); ++itr) {
        if (itr->second / 2 > 0) {
            if (itr->second / 4 > 0) 
                ans = max(ans, itr->first * itr->first);
            else 
                ans = max(ans, use * itr->first);
            use = itr->first;
        }
    }
    cout << ans << endl;
    return 0;
}

Submission Info

Submission Time
Task C - Make a Rectangle
User kage
Language C++14 (GCC 5.4.1)
Score 300
Code Size 1299 Byte
Status AC
Exec Time 47 ms
Memory 6528 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 41 ms 4608 KB
2.txt AC 7 ms 256 KB
3.txt AC 47 ms 6528 KB
4.txt AC 35 ms 2816 KB
5.txt AC 7 ms 256 KB
6.txt AC 12 ms 256 KB
7.txt AC 13 ms 256 KB
8.txt AC 6 ms 256 KB
9.txt AC 22 ms 3456 KB
sample1.txt AC 1 ms 256 KB
sample2.txt AC 1 ms 256 KB
sample3.txt AC 1 ms 256 KB