結果

問題 No.5 数字のブロック
ユーザー ゆうPゆうP
提出日時 2024-03-02 12:04:55
言語 Go
(1.22.1)
結果
AC  
実行時間 60 ms / 5,000 ms
コード長 449 bytes
コンパイル時間 12,404 ms
コンパイル使用メモリ 217,232 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-02 12:05:13
合計ジャッジ時間 15,083 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,676 KB
testcase_01 AC 1 ms
6,676 KB
testcase_02 AC 1 ms
6,676 KB
testcase_03 AC 35 ms
6,676 KB
testcase_04 AC 20 ms
6,676 KB
testcase_05 AC 44 ms
6,676 KB
testcase_06 AC 28 ms
6,676 KB
testcase_07 AC 25 ms
6,676 KB
testcase_08 AC 32 ms
6,676 KB
testcase_09 AC 13 ms
6,676 KB
testcase_10 AC 46 ms
6,676 KB
testcase_11 AC 21 ms
6,676 KB
testcase_12 AC 37 ms
6,676 KB
testcase_13 AC 42 ms
6,676 KB
testcase_14 AC 2 ms
6,676 KB
testcase_15 AC 2 ms
6,676 KB
testcase_16 AC 46 ms
6,676 KB
testcase_17 AC 53 ms
6,676 KB
testcase_18 AC 49 ms
6,676 KB
testcase_19 AC 60 ms
6,676 KB
testcase_20 AC 1 ms
6,676 KB
testcase_21 AC 1 ms
6,676 KB
testcase_22 AC 1 ms
6,676 KB
testcase_23 AC 1 ms
6,676 KB
testcase_24 AC 3 ms
6,676 KB
testcase_25 AC 4 ms
6,676 KB
testcase_26 AC 1 ms
6,676 KB
testcase_27 AC 1 ms
6,676 KB
testcase_28 AC 1 ms
6,676 KB
testcase_29 AC 19 ms
6,676 KB
testcase_30 AC 12 ms
6,676 KB
testcase_31 AC 1 ms
6,676 KB
testcase_32 AC 1 ms
6,676 KB
testcase_33 AC 2 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// no5
package main

import (
	"fmt"
	"sort"
)

func main() {
	var wBox int // 箱幅
	fmt.Scan(&wBox)

	var n int // 要素数
	fmt.Scan(&n)

	list := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&list[i])
	}
	// 並べ替え
	sort.Slice(list, func(x, y int) bool { return list[x] < list[y] })

	// 判定
	var total, ans int
	for i := 0; i < n; i++ {
		if (total + list[i]) <= wBox {
			total += list[i]
			ans++
		}
	}
	fmt.Println(ans)
}
0