結果
問題 |
No.5 数字のブロック
|
ユーザー |
![]() |
提出日時 | 2017-03-04 11:05:24 |
言語 | Go (1.23.4) |
結果 |
WA
|
実行時間 | - |
コード長 | 604 bytes |
コンパイル時間 | 14,846 ms |
コンパイル使用メモリ | 220,672 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-23 01:29:21 |
合計ジャッジ時間 | 14,994 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 24 WA * 10 |
ソースコード
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) w_list := getIntList(sc) sort.Ints(w_list) boxes_width := 0 for i, w := range w_list { if boxes_width+w <= l { boxes_width += w } else { fmt.Println(i) break } } }