結果

問題 No.5 数字のブロック
ユーザー cm-arai
提出日時 2021-01-02 16:09:37
言語 Go
(1.23.4)
結果
WA  
実行時間 -
コード長 486 bytes
コンパイル時間 11,296 ms
コンパイル使用メモリ 224,012 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-12 05:00:09
合計ジャッジ時間 12,972 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 27 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"fmt"
	"sort"
)

func scan() (L int, N int, W []int) {
	fmt.Scan(&L)
	fmt.Scan(&N)
	for i := 0; i < N; i++ {
		var w int
		fmt.Scan(&w)
		W = append(W, w)
	}
	return L, N, W
}

func main() {
	L, _, W := scan()
	// L, _, W := 16, 3, []int{10, 5, 7}
	// L, _, W := 100, 10, []int{14, 85, 77, 26, 50, 45, 66, 79, 10, 3}
	sort.IntSlice(W).Sort()

	count := 0
	sum := 0

	for _, w := range W {
		sum += w
		if sum >= L {
			break
		}
		count++
	}
	fmt.Print(count)
}
0