結果
| 問題 |
No.112 ややこしい鶴亀算
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-05-12 18:03:07 |
| 言語 | Go (1.23.4) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 645 bytes |
| コンパイル時間 | 10,755 ms |
| コンパイル使用メモリ | 226,588 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-10 04:07:30 |
| 合計ジャッジ時間 | 11,535 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 23 |
ソースコード
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 = uniqs[keys[0]], uniqs[keys[1]]
} else {
t, c = uniqs[keys[1]], uniqs[keys[0]]
}
} else {
if (keys[0]+2)/2 == n {
c = uniqs[keys[0]]
} else {
t = uniqs[keys[0]]
}
}
fmt.Println(c, t)
}