結果
問題 | No.706 多眼生物の調査 |
ユーザー |
![]() |
提出日時 | 2018-06-30 00:14:00 |
言語 | Go (1.23.4) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 1,630 bytes |
コンパイル時間 | 11,698 ms |
コンパイル使用メモリ | 227,212 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-22 03:33:29 |
合計ジャッジ時間 | 12,415 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 5 |
ソースコード
package mainimport ("bufio""fmt""os""strconv""strings")type Scanner struct {reader *bufio.Readerbuffer []stringpointer int}func NewScanner() *Scanner {return &Scanner{reader: bufio.NewReaderSize(os.Stdin, 4096),pointer: 0,}}func (self *Scanner) NextLine() string {var buffer []bytefor {line, isPrefix, _ := self.reader.ReadLine()buffer = append(buffer, line...)if !isPrefix {break}}return string(buffer)}func (self *Scanner) Next() string {if self.pointer >= len(self.buffer) {line := self.NextLine()self.buffer = strings.Fields(line)self.pointer = 0}self.pointer++return self.buffer[self.pointer-1]}func (self *Scanner) NextInt() int {s := self.Next()i, _ := strconv.ParseInt(s, 10, 32)return int(i)}func (self *Scanner) NextLong() int64 {s := self.Next()l, _ := strconv.ParseInt(s, 10, 64)return int64(l)}func (self *Scanner) NextFloat() float32 {s := self.Next()f, _ := strconv.ParseFloat(s, 32)return float32(f)}func (self *Scanner) NextDouble() float64 {s := self.Next()d, _ := strconv.ParseFloat(s, 64)return float64(d)}func main() {cin := NewScanner()N := cin.NextInt()S := make([]string, N)for i := 0; i < N; i++ {S[i] = cin.Next()}freq := make([]int, 1000+1)for i := 0; i < N; i++ {cnt := 0for _, c := range S[i] {if c == '^' {cnt++}}freq[cnt]++}maxFreq := 0maxCount := 0for i := 0; i < 1000+1; i++ {if freq[i] > maxCount {maxFreq = imaxCount = freq[i]} else if freq[i] == maxCount {maxFreq = i}}fmt.Println(maxFreq)}