Submission #2245463


Source Code Expand

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.IO;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        private static long Solve(int N, long[] A)
        {
            var dict = new Dictionary<long, int>();
            foreach (long a in A)
            {
                if (!dict.ContainsKey(a)) { dict[a] = 0; }
                ++dict[a];
            }
            var X = dict.Where(pair => pair.Value >= 2).OrderByDescending(pair => pair.Key);
            if (X.Count() == 0) { return 0; }
            var x = X.First();
            dict[x.Key] -= 2;
            var Y = dict.Where(pair => pair.Value >= 2).OrderByDescending(pair => pair.Key);
            if (Y.Count() == 0) { return 0; }
            var y = Y.First();
            return x.Key * y.Key;
        }
        static void Main(string[] args)
        {
            int N = ReadInt();
            long[] A = ReadLongs();
            Console.WriteLine(Solve(N, A));
        }
    }
}

Submission Info

Submission Time
Task C - Make a Rectangle
User M_Saito
Language C# (Mono 4.6.2.0)
Score 300
Code Size 1654 Byte
Status AC
Exec Time 165 ms
Memory 30176 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 133 ms 30176 KB
2.txt AC 54 ms 14432 KB
3.txt AC 97 ms 24544 KB
4.txt AC 165 ms 26976 KB
5.txt AC 55 ms 16480 KB
6.txt AC 80 ms 19424 KB
7.txt AC 81 ms 19424 KB
8.txt AC 49 ms 11744 KB
9.txt AC 58 ms 19808 KB
sample1.txt AC 29 ms 13396 KB
sample2.txt AC 28 ms 11360 KB
sample3.txt AC 33 ms 11476 KB