結果

問題 No.1238 選抜クラス
ユーザー aru aruaru aru
提出日時 2020-10-23 21:28:07
言語 Go
(1.22.1)
結果
WA  
実行時間 -
コード長 1,993 bytes
コンパイル時間 12,044 ms
コンパイル使用メモリ 212,860 KB
実行使用メモリ 194,828 KB
最終ジャッジ日時 2023-09-28 15:42:57
合計ジャッジ時間 16,398 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
16,412 KB
testcase_01 AC 12 ms
18,464 KB
testcase_02 AC 16 ms
30,780 KB
testcase_03 AC 10 ms
14,364 KB
testcase_04 AC 12 ms
14,364 KB
testcase_05 AC 11 ms
14,364 KB
testcase_06 AC 11 ms
14,368 KB
testcase_07 AC 15 ms
24,636 KB
testcase_08 AC 15 ms
30,780 KB
testcase_09 AC 20 ms
41,024 KB
testcase_10 AC 15 ms
26,684 KB
testcase_11 AC 18 ms
38,976 KB
testcase_12 AC 16 ms
32,832 KB
testcase_13 AC 16 ms
32,828 KB
testcase_14 AC 15 ms
30,780 KB
testcase_15 AC 19 ms
41,020 KB
testcase_16 AC 18 ms
38,972 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 154 ms
193,312 KB
testcase_20 WA -
testcase_21 AC 135 ms
182,984 KB
testcase_22 WA -
testcase_23 AC 127 ms
177,408 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 152 ms
190,436 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 33 ms
74,592 KB
testcase_31 WA -
testcase_32 AC 100 ms
168,944 KB
testcase_33 AC 14 ms
24,632 KB
testcase_34 WA -
testcase_35 AC 41 ms
91,128 KB
testcase_36 AC 22 ms
49,212 KB
testcase_37 AC 35 ms
78,804 KB
testcase_38 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

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

var sc = bufio.NewScanner(os.Stdin)
var wr = bufio.NewWriter(os.Stdout)

func out(x ...interface{}) {
	fmt.Fprintln(wr, x...)
}

func getI() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getF() float64 {
	sc.Scan()
	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getI()
	}
	return ret
}

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

const mod = int(1e9 + 7)

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	// this template is new version.
	// use getI(), getS(), getInts(), getF()
	N, K := getI(), getI()
	a := getInts(N)

	var dp [101][101][10100]int32
	// for i := 0; i <= N; i++ {
	// 	for j := 0; j <= i; j++ {
	// 		for k := 0; k < 10100; k++ {
	// 			dp[i][j][k] = -1
	// 		}
	// 	}
	// }

	dp[0][0][0] = 1
	for i := 1; i <= N; i++ {
		for j := 0; j <= i; j++ {
			for k := 0; k <= 10000; k++ {
				if dp[i-1][j][k] != 0 {
					//					out("pass", i, j, k, dp[i-1][j][k], a[i-1])
					dp[i][j][k] += dp[i-1][j][k]
					dp[i][j+1][k+a[i-1]] += dp[i-1][j][k]
				}
			}
			//			out(i, j, dp[i][j][:100*N])
		}
	}
	ans := 0
	for i := 1; i <= N; i++ {
		for j := K * i; j <= 10000; j++ {
			ans += int(dp[N][i][j])
			ans %= mod
		}
	}
	out(ans)
}
0