結果

問題 No.893 お客様を誘導せよ
ユーザー neko_the_shadowneko_the_shadow
提出日時 2019-12-13 15:58:26
言語 Go
(1.22.1)
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 875 bytes
コンパイル時間 11,731 ms
コンパイル使用メモリ 209,252 KB
実行使用メモリ 10,128 KB
最終ジャッジ日時 2023-09-09 11:15:12
合計ジャッジ時間 13,860 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 4 ms
5,540 KB
testcase_03 AC 14 ms
7,932 KB
testcase_04 AC 15 ms
7,924 KB
testcase_05 AC 12 ms
7,856 KB
testcase_06 AC 10 ms
7,868 KB
testcase_07 AC 2 ms
4,384 KB
testcase_08 AC 31 ms
10,128 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 3 ms
4,380 KB
testcase_12 AC 4 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

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

func main() {
	n := readInt()
	a := make([][]int, 0)
	sum := 0
	for i := 0; i < n; i++ {
		p := readInt()
		a = append(a, []int{})
		sum += p
		for j := 0; j < p; j++ {
			a[i] = append(a[i], readInt())
		}
	}

	b := []int{}
	x := 0
	for i := 0; i < sum; i++ {
		for len(a[x]) == 0 {
			x = (x + 1) % n
		}
		b = append(b, a[x][0])
		a[x] = a[x][1:]
		x = (x + 1) % n
	}

	c := []string{}
	for _, v := range b {
		c = append(c, strconv.Itoa(v))
	}
	fmt.Println(strings.Join(c, " "))
}

var stdin *bufio.Scanner

func read() string {
	if stdin == nil {
		stdin = bufio.NewScanner(os.Stdin)
		stdin.Split(bufio.ScanWords)
		stdin.Buffer(make([]byte, bufio.MaxScanTokenSize), int(math.MaxInt32))
	}
	stdin.Scan()
	return stdin.Text()
}

func readInt() int {
	n, _ := strconv.Atoi(read())
	return n
}
0