結果
| 問題 |
No.5 数字のブロック
|
| コンテスト | |
| ユーザー |
Kgm1500
|
| 提出日時 | 2017-03-04 11:03:19 |
| 言語 | Go (1.23.4) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 607 bytes |
| コンパイル時間 | 14,668 ms |
| コンパイル使用メモリ | 221,736 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-23 01:28:58 |
| 合計ジャッジ時間 | 12,996 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | WA * 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)
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 - 1)
break
}
}
}
Kgm1500