Submission #2526175
Source Code Expand
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class Main { int n; public static void main(String args[]) { new Main().run(); } void run() { FastReader sc = new FastReader(); n = sc.nextInt(); SortedMap<Integer, Integer> counts = new TreeMap<>(Collections.reverseOrder()); for (int i = 0; i < n; i++) { int a = sc.nextInt(); if (!counts.containsKey(a)) { counts.put(a, 1); } else { counts.put(a, counts.get(a) + 1); } } int first = 0; int second = 0; for (Map.Entry<Integer, Integer> entry : counts.entrySet()) { int value = entry.getValue(); if (value >= 4) { if (first == 0) { first = entry.getKey(); } second = entry.getKey(); break; } else if (value >= 2) { if (first == 0) { first = entry.getKey(); } else { second = entry.getKey(); break; } } } System.out.println((long)first * second); } static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine() { String str = ""; try { str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } } }
Submission Info
Submission Time | |
---|---|
Task | C - Make a Rectangle |
User | ynish |
Language | Java8 (OpenJDK 1.8.0) |
Score | 300 |
Code Size | 2554 Byte |
Status | AC |
Exec Time | 285 ms |
Memory | 46024 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 | 260 ms | 43816 KB |
2.txt | AC | 182 ms | 31596 KB |
3.txt | AC | 285 ms | 46024 KB |
4.txt | AC | 250 ms | 40708 KB |
5.txt | AC | 178 ms | 33652 KB |
6.txt | AC | 212 ms | 41688 KB |
7.txt | AC | 201 ms | 36700 KB |
8.txt | AC | 171 ms | 31848 KB |
9.txt | AC | 219 ms | 32920 KB |
sample1.txt | AC | 70 ms | 21204 KB |
sample2.txt | AC | 68 ms | 17748 KB |
sample3.txt | AC | 71 ms | 20436 KB |