Submission #2856952


Source Code Expand

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	n := scanInt(sc)
	found := make(map[int]int, n)
	candidates := make([]int, 0)

	for i := 0; i < n; i++ {
		l := scanInt(sc)
		if found[l] >= 0 {
			found[l] += 1
			if found[l] == 2 || found[l] == 4 {
				candidates = append(candidates, l)
			}
			if found[l] == 4 {
				found[l] = -1
			}
		}
	}

	if len(candidates) < 2 {
		fmt.Println(0)
		return
	}

	sort.Ints(candidates)
	a := candidates[len(candidates)-1]
	b := candidates[len(candidates)-2]
	fmt.Println(a * b)
}

func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	val, _ := strconv.Atoi(sc.Text())
	return val
}

Submission Info

Submission Time
Task C - Make a Rectangle
User ryym
Language Go (1.6)
Score 300
Code Size 759 Byte
Status AC
Exec Time 52 ms
Memory 5120 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 49 ms 4608 KB
2.txt AC 16 ms 1920 KB
3.txt AC 47 ms 4608 KB
4.txt AC 52 ms 5120 KB
5.txt AC 15 ms 1664 KB
6.txt AC 29 ms 2816 KB
7.txt AC 29 ms 2688 KB
8.txt AC 13 ms 1664 KB
9.txt AC 24 ms 2816 KB
sample1.txt AC 1 ms 640 KB
sample2.txt AC 1 ms 640 KB
sample3.txt AC 1 ms 640 KB