Submission #2526132
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 >= 2) { if (first == 0) { first = entry.getKey(); } else { second = entry.getKey(); break; } } } System.out.println(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 | 0 |
Code Size | 2345 Byte |
Status | WA |
Exec Time | 289 ms |
Memory | 43864 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 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 | WA | 257 ms | 43032 KB |
2.txt | WA | 181 ms | 29804 KB |
3.txt | WA | 289 ms | 43404 KB |
4.txt | WA | 252 ms | 41128 KB |
5.txt | WA | 180 ms | 29036 KB |
6.txt | WA | 221 ms | 40548 KB |
7.txt | WA | 214 ms | 43864 KB |
8.txt | WA | 155 ms | 31852 KB |
9.txt | AC | 221 ms | 30852 KB |
sample1.txt | AC | 71 ms | 19152 KB |
sample2.txt | AC | 70 ms | 22996 KB |
sample3.txt | AC | 74 ms | 20308 KB |