結果

問題 No.112 ややこしい鶴亀算
ユーザー yukirin
提出日時 2015-05-12 18:00:15
言語 Go
(1.23.4)
結果
WA  
実行時間 -
コード長 610 bytes
コンパイル時間 11,437 ms
コンパイル使用メモリ 221,836 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-10 04:07:01
合計ジャッジ時間 11,876 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 1
other AC * 4 WA * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

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

func main() {
	var n, t, c int

	keys := make([]int, 0, 2)
	uniqs := make(map[int]int)

	fmt.Scanln(&n)
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()

	for _, v := range strings.Fields(scanner.Text()) {
		val, _ := strconv.Atoi(v)
		uniqs[val]++
	}

	for k := range uniqs {
		keys = append(keys, k)
	}

	if len(keys) == 2 {
		if keys[0] < keys[1] {
			t, c = keys[0], keys[1]
		} else {
			t, c = keys[1], keys[0]
		}
	} else {
		if (keys[0]+2)%n == 0 {
			c = uniqs[keys[0]]
		} else {
			t = keys[0]
		}
	}

	fmt.Println(c, t)
}
0