Submission #1996234


Source Code Expand

#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> P;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ull d[100000],dp[100][100];

int main(){
  vll vec;
  cin >> n;
  rep(i,0,n){
    cin >> m;
    vec.pb(m);
  }
  sort(all(vec),greater<int>());
  m = 0;
  l = vec[0];
  ll ans = 0;
  short count = 0;
  rep(i,0,n){
    if(vec[i] == l)m++;
    else{
      if(m >= 4){
        //4つ同じやつ
        if(ans == 0)ans = l * l;
        else ans *= l;
        count += 2;
        break;
      }else if(m >= 2){
        //2つ同じやつがあったら
        if(ans != 0){
          //2つ目の辺
          ans *= l;
          count++;
          break;
        }else{
          //1つ目の辺
          count++;
          ans = l;
        }
      }
      m = 1;
      l = vec[i];
    }
  }
  print(ans);
  return 0;
}

Submission Info

Submission Time
Task C - Make a Rectangle
User shadowlink_0122
Language C++14 (GCC 5.4.1)
Score 300
Code Size 1620 Byte
Status AC
Exec Time 47 ms
Memory 1400 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 47 ms 1400 KB
2.txt AC 22 ms 892 KB
3.txt AC 47 ms 1400 KB
4.txt AC 47 ms 1400 KB
5.txt AC 22 ms 892 KB
6.txt AC 44 ms 1400 KB
7.txt AC 44 ms 1400 KB
8.txt AC 18 ms 892 KB
9.txt AC 24 ms 892 KB
sample1.txt AC 1 ms 256 KB
sample2.txt AC 1 ms 256 KB
sample3.txt AC 1 ms 256 KB