結果

問題 No.203 ゴールデン・ウィーク(1)
ユーザー gogotea
提出日時 2015-05-08 22:28:26
言語 Go1.4
(1.4.2)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 796 bytes
コンパイル時間 2,176 ms
コンパイル使用メモリ 33,040 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-18 08:58:18
合計ジャッジ時間 2,940 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

func main() {
	sc := NewScanner(os.Stdin)
	line1, _ := sc.NextLine()
	line2, _ := sc.NextLine()
	line := line1 + line2

	fmt.Println(solve(line))
}

func solve(s string) int {
	var cnt, max int
	for _, c := range s {
		switch {
		case c == 'o':
			cnt++
		default:
			cnt = 0
		}
		if cnt > max {
			max = cnt
		}
	}
	return max
}

type scanner struct {
	*bufio.Scanner
}

func NewScanner(r io.Reader) *scanner {
	return &scanner{
		bufio.NewScanner(r),
	}
}

func (s *scanner) NextLine() (string, error) {
	s.Scanner.Split(bufio.ScanLines)
	return s.nextToken()
}

func (s *scanner) nextToken() (string, error) {
	sc := s.Scanner
	if sc.Scan() {
		return sc.Text(), nil
	}
	if sc.Err() != nil {
		return "", sc.Err()
	}
	return "", io.EOF
}
0