Submission #2857291
Source Code Expand
using System; using System.Linq; using System.Collections.Generic; using static System.Console; class Program { internal static void Main(string[] args) { int N = int.Parse(ReadLine()); var A = ReadLine().Split(' ').Select(s => long.Parse(s)).ToList(); var dic = new Dictionary<long, int>(); for (int i = 0; i < N; i++) { if (dic.ContainsKey(A[i])) { dic[A[i]]++; } else { dic.Add(A[i], 1); } } var max = dic.OrderByDescending(kvp => kvp.Key) .Where(kvp => kvp.Value >= 4).ToArray(); long sei = 0L; if (max.Length != 0) { sei = max[0].Key * max[0].Key; } var values = dic.OrderByDescending(kvp => kvp.Key) .Where(kvp => kvp.Value >= 2) .Select(kvp => kvp.Key).ToArray(); if (values.Length < 2) { WriteLine(0); return; } long cho = values[0] * values[1]; WriteLine(Math.Max(sei, cho)); } }
Submission Info
Submission Time | |
---|---|
Task | C - Make a Rectangle |
User | r_k |
Language | C# (Mono 4.6.2.0) |
Score | 300 |
Code Size | 1125 Byte |
Status | AC |
Exec Time | 180 ms |
Memory | 26336 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | ||||
Status |
|
|
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 | 149 ms | 26208 KB |
2.txt | AC | 56 ms | 15072 KB |
3.txt | AC | 180 ms | 26336 KB |
4.txt | AC | 122 ms | 23264 KB |
5.txt | AC | 56 ms | 13024 KB |
6.txt | AC | 81 ms | 20448 KB |
7.txt | AC | 81 ms | 20448 KB |
8.txt | AC | 51 ms | 14560 KB |
9.txt | AC | 99 ms | 19168 KB |
sample1.txt | AC | 32 ms | 11488 KB |
sample2.txt | AC | 32 ms | 11488 KB |
sample3.txt | AC | 31 ms | 11488 KB |