結果

問題 No.714 回転寿司屋のシミュレート
ユーザー tsuchinaga
提出日時 2019-03-28 09:13:33
言語 Go
(1.23.4)
結果
AC  
実行時間 12 ms / 2,000 ms
コード長 929 bytes
コンパイル時間 14,232 ms
コンパイル使用メモリ 231,800 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-12 09:47:24
合計ジャッジ時間 15,402 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())

	type client map[string]int
	clients := make(map[int]client, 0)

	for i := 0; i < n; i++ {
		sc.Scan()
		d, _ := strconv.Atoi(sc.Text())
		switch d {
		case 0: // 入店
			sc.Scan()
			n, _ := strconv.Atoi(sc.Text())
			sc.Scan()
			m, _ := strconv.Atoi(sc.Text())
			c := client{}
			for j := 0; j < m; j++ {
				sc.Scan()
				c[sc.Text()]++
			}
			clients[n] = c
		case 1: // サラキタル
			sc.Scan()
			s := sc.Text()
			catch := false
			for j := 1; j <= 20; j++ {
				if c, ok := clients[j]; ok {
					if c[s] > 0 {
						c[s]--
						catch = true
						fmt.Println(j)
						break
					}
				}
			}
			if !catch {
				fmt.Println(-1)
			}
		case 2: // 退店
			sc.Scan()
			n, _ := strconv.Atoi(sc.Text())
			delete(clients, n)
		}
	}
}
0