結果
問題 | No.5 数字のブロック |
ユーザー |
![]() |
提出日時 | 2016-06-11 14:47:34 |
言語 | Go (1.23.4) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 720 bytes |
コンパイル時間 | 12,046 ms |
コンパイル使用メモリ | 234,720 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-18 08:40:11 |
合計ジャッジ時間 | 12,928 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
ソースコード
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) n := nextInt(sc) wList := nextIntList(sc) sort.Ints(wList) for i, v := range wList { l -= v if l < 0 { fmt.Println(i) break } else if i == n-1 { fmt.Println(n) } } }