結果

問題 No.5 数字のブロック
ユーザー t_murano
提出日時 2016-06-11 14:45:07
言語 Go
(1.23.4)
結果
WA  
実行時間 -
コード長 674 bytes
コンパイル時間 14,403 ms
コンパイル使用メモリ 223,512 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-11 05:11:57
合計ジャッジ時間 16,489 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 24 WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextIntList(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() {
	sc := bufio.NewScanner(os.Stdin)

	l := nextInt(sc)
	nextInt(sc)
	wList := nextIntList(sc)
	sort.Ints(wList)
	for i, v := range wList {
		l -= v
		if l < 0 {
			fmt.Println(i)
			break
		}
	}
}
0