結果

問題 No.78 クジ付きアイスバー
ユーザー yukirinyukirin
提出日時 2016-03-05 19:41:51
言語 Go
(1.22.1)
結果
WA  
実行時間 -
コード長 733 bytes
コンパイル時間 11,294 ms
コンパイル使用メモリ 240,508 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-19 06:59:24
合計ジャッジ時間 12,713 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
5,248 KB
testcase_02 WA -
testcase_03 AC 1 ms
5,376 KB
testcase_04 WA -
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 AC 1 ms
5,376 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 1 ms
5,376 KB
testcase_24 AC 1 ms
5,376 KB
testcase_25 AC 1 ms
5,376 KB
testcase_26 AC 1 ms
5,376 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 1 ms
5,376 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	n, k := nextInt(), nextInt()
	s := nextLine()
	ns := make([]int, n)
	for i, r := range s {
		v, _ := strconv.Atoi(string(r))
		ns[i] = v
	}

	c, w := 0, 0
	for i, v := range ns {
		if i+1 == k {
			fmt.Println(c)
			return
		}

		if w == 0 {
			c++
		} else {
			w--
		}
		w += v

		if w > n-1-i {
			fmt.Println(c)
			return
		}
	}

	t := (k / n) * c
	k %= n
	for i := 0; i < k; i++ {
		t++
		if w == 0 {
			c++
		} else {
			w--
		}
		w += ns[i]
	}
	fmt.Println(c)

}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextLine())
	return i
}
0