Submission #8893119


Source Code Expand

import java.util.*;


public class Main{
	
	public static void main(String... args){
		Scanner scan = new Scanner(System.in);
		
		// input
		int num = scan.nextInt();
		long[] edges = new long[100000];
		for(int i = 0; i < num; i++){
			edges[i] = scan.nextLong();
		}
		
		// search
		Arrays.sort(edges);
		long memory = edges[99999];
		int count = 1;
		long firstLen = 0;
		long secondLen = -1;
		for(int i = 99998; i >= 0; i--){
			if(memory == edges[i]){
				count++;
				if(count == 2){
					if(edges[i] > firstLen){
						secondLen = firstLen;
						firstLen = edges[i];
						count = 0;
					} else if(edges[i] > secondLen){
						secondLen = edges[i];
						count = 0;
					}
				}
			} else {
				memory = edges[i];
				count = 1;
			}
		}
		
		// output
		long area = 0;
		if(firstLen * secondLen > 0){
			area = firstLen * secondLen;
		}
		System.out.println(area);
		
	}
	
}

Submission Info

Submission Time
Task C - Make a Rectangle
User mikhail
Language Java8 (OpenJDK 1.8.0)
Score 300
Code Size 936 Byte
Status AC
Exec Time 503 ms
Memory 50992 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 503 ms 47884 KB
2.txt AC 389 ms 43536 KB
3.txt AC 481 ms 47928 KB
4.txt AC 483 ms 48464 KB
5.txt AC 377 ms 46116 KB
6.txt AC 475 ms 46872 KB
7.txt AC 466 ms 50992 KB
8.txt AC 360 ms 43672 KB
9.txt AC 390 ms 43916 KB
sample1.txt AC 117 ms 23508 KB
sample2.txt AC 101 ms 20564 KB
sample3.txt AC 99 ms 22612 KB