結果

問題 No.35 タイパー高橋
ユーザー yo-kondoyo-kondo
提出日時 2018-03-10 17:05:44
言語 Go
(1.22.1)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,138 bytes
コンパイル時間 13,156 ms
コンパイル使用メモリ 226,888 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-22 15:42:43
合計ジャッジ時間 13,862 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,248 KB
testcase_02 AC 2 ms
5,248 KB
testcase_03 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

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

// エントリポイント
func main() {
	in := bufio.NewScanner(os.Stdin)
	// 1  ゲームの区間の数
	in.Scan()
	input1 := in.Text()
	// 制限時間と入力する文字列
	input2 := make([]string, 0)
	for in.Scan() {
		input2 = append(input2, in.Text())
	}

	fmt.Println(typing(input1, input2))
}

// タイピングで、タイプできた文字数、タイプできなかった文字数を返す。
func typing(gameCount string, timeAndInput []string) string {
	_ = gameCount
	typeCount := 0
	missCount := 0

	for _, v := range timeAndInput {
		sp := strings.Split(v, " ")
		// タイプできる文字数
		limit, _ := strconv.Atoi(sp[0])
		// 1ミリ秒でタイプできる文字数 = 12文字タイプ / 1000ミリ秒 = 0.012
		// 小数を切り捨てるためにintに変換
		typeChar := int(float64(0.012) * float64(limit))
		inputLen := len(sp[1])
		if typeChar >= inputLen {
			typeCount += inputLen
		} else {
			typeCount += typeChar
			missCount += inputLen - typeChar
		}
	}

	return strconv.Itoa(typeCount) + " " + strconv.Itoa(missCount)
}
0