結果
問題 |
No.1238 選抜クラス
|
ユーザー |
![]() |
提出日時 | 2020-09-25 23:04:30 |
言語 | Go (1.23.4) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,153 bytes |
コンパイル時間 | 11,672 ms |
コンパイル使用メモリ | 223,164 KB |
実行使用メモリ | 13,756 KB |
最終ジャッジ日時 | 2024-06-28 07:17:01 |
合計ジャッジ時間 | 15,179 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 14 TLE * 1 -- * 21 |
ソースコード
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 } func main() { defer flush() 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 } var stdoutWriter = bufio.NewWriter(os.Stdout) func flush() { stdoutWriter.Flush() } func println(args ...interface{}) (int, error) { return fmt.Fprintln(stdoutWriter, args...) }