Submission #2526146


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((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 0
Code Size 2351 Byte
Status WA
Exec Time 285 ms
Memory 45824 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 300
Status
AC × 3
AC × 12
WA × 3
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 285 ms 43248 KB
2.txt AC 175 ms 29880 KB
3.txt AC 276 ms 45824 KB
4.txt AC 252 ms 41888 KB
5.txt WA 184 ms 26724 KB
6.txt AC 221 ms 41304 KB
7.txt WA 212 ms 43868 KB
8.txt WA 171 ms 28260 KB
9.txt AC 212 ms 33988 KB
sample1.txt AC 70 ms 19156 KB
sample2.txt AC 69 ms 19284 KB
sample3.txt AC 70 ms 19156 KB