結果

問題 No.1238 選抜クラス
ユーザー c-yanc-yan
提出日時 2020-09-25 23:01:05
言語 Go
(1.22.1)
結果
WA  
実行時間 -
コード長 1,214 bytes
コンパイル時間 12,833 ms
コンパイル使用メモリ 203,152 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-10 16:08:09
合計ジャッジ時間 17,874 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

package main

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

const (
	m = 1000000007
)

var (
	N int
	K int
	A []int
)

func f(i, scores, peoples int) int {
	result := 0
	for j := i; j < N; j++ {
		if (scores+A[j])/(peoples+1) < K {
			break
		}
		result++
		result += f(j+1, scores+A[j], peoples+1)
		result %= m
	}
	return result % m
}

func main() {
	N = readInt()
	K = readInt()
	A = make([]int, N)
	for i := 0; i < N; i++ {
		A[i] = readInt()
	}
	sort.Sort(sort.Reverse(sort.IntSlice(A)))
	println(f(0, 0, 0))
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}

func printIntln(v ...int) {
	if len(v) == 0 {
		return
	}
	b := make([]byte, 0, 4096)
	for i := 0; i < len(v)-1; i++ {
		b = append(b, strconv.Itoa(v[i])...)
		b = append(b, " "...)
	}
	b = append(b, strconv.Itoa(v[len(v)-1])...)
	fmt.Println(string(b))
}
0