結果
問題 | No.516 赤と青の風船 |
ユーザー |
![]() |
提出日時 | 2017-05-28 21:23:17 |
言語 | Go (1.23.4) |
結果 |
AC
|
実行時間 | 1 ms / 2,000 ms |
コード長 | 1,193 bytes |
コンパイル時間 | 14,659 ms |
コンパイル使用メモリ | 230,248 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-21 15:16:17 |
合計ジャッジ時間 | 15,153 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 6 |
ソースコード
package mainimport ("bufio""fmt""log""os""strconv")func main() {log.SetFlags(log.Lshortfile)// log.Println("hello")sc := newScanner()var red, blue intfor i := 0; i < 3; i++ {s := sc.nextLine()switch s {case "RED":red++case "BLUE":blue++}}if red > blue {fmt.Println("RED")} else {fmt.Println("BLUE")}// fmt.Println(ans)}type scanner struct {r *bufio.Readerbuf []bytep int}func newScanner() *scanner {rdr := bufio.NewReaderSize(os.Stdin, 1000)return &scanner{r: rdr}}func (s *scanner) next() string {s.pre()start := s.pfor ; s.p < len(s.buf); s.p++ {if s.buf[s.p] == ' ' {break}}result := string(s.buf[start:s.p])s.p++return result}func (s *scanner) nextLine() string {s.pre()start := s.ps.p = len(s.buf)return string(s.buf[start:])}func (s *scanner) nextInt() int {v, _ := strconv.Atoi(s.next())return v}func (s *scanner) pre() {if s.p >= len(s.buf) {s.readLine()s.p = 0}}func (s *scanner) readLine() {s.buf = make([]byte, 0)for {l, p, e := s.r.ReadLine()if e != nil {panic(e)}s.buf = append(s.buf, l...)if !p {break}}}