結果
| 問題 |
No.5 数字のブロック
|
| ユーザー |
Kgm1500
|
| 提出日時 | 2017-03-04 11:39:33 |
| 言語 | Go (1.23.4) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 652 bytes |
| コンパイル時間 | 11,085 ms |
| コンパイル使用メモリ | 236,680 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-18 10:55:24 |
| 合計ジャッジ時間 | 11,933 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 34 |
ソースコード
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)
boxesWidth := 0
var boxesNum, b int
for boxesNum = 0; boxesNum < n; boxesNum++ {
b = boxesWidth + wList[boxesNum]
if b > l {
break
}
boxesWidth = b
}
fmt.Println(boxesNum)
}
Kgm1500