結果
問題 |
No.5 数字のブロック
|
ユーザー |
![]() |
提出日時 | 2017-03-04 11:23:36 |
言語 | Go (1.23.4) |
結果 |
WA
|
実行時間 | - |
コード長 | 623 bytes |
コンパイル時間 | 15,307 ms |
コンパイル使用メモリ | 241,344 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-23 01:29:38 |
合計ジャッジ時間 | 13,211 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 WA * 24 |
ソースコード
package main import ( "bufio" "fmt" "os" "sort" "strconv" "strings" ) func getIntList(sc *bufio.Scanner) []int { sc.Scan() input := strings.Split(sc.Text(), " ") result := make([]int, len(input)) for i, v := range input { if j, e := strconv.Atoi(v); e != nil { panic(e) } else { result[i] = j } } return result } func main() { var l, n int fmt.Scan(&l, &n) sc := bufio.NewScanner(os.Stdin) wList := getIntList(sc) sort.Ints(wList) boxesNum := 0 for boxesWidth := 0; ; { if boxesNum < n && boxesWidth+wList[boxesNum] <= l { boxesNum++ } else { break } } fmt.Print(boxesNum) }