結果
問題 | No.156 キャンディー・ボックス |
ユーザー |
|
提出日時 | 2024-03-31 02:52:15 |
言語 | Go (1.23.4) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 988 bytes |
コンパイル時間 | 11,955 ms |
コンパイル使用メモリ | 238,936 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-09-30 17:49:14 |
合計ジャッジ時間 | 11,823 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
// No.156 キャンディー・ボックスpackage mainimport ("bufio""fmt""os""sort""strconv")var sc = bufio.NewScanner(os.Stdin)var wr = bufio.NewWriter(os.Stdout)func next() string {sc.Scan()return sc.Text()}func nextInt() int {i, _ := strconv.Atoi(next())return i}func nextFloat() float64 {f, _ := strconv.ParseFloat(next(), 64)return f}func nextInts(n int) []int {ret := make([]int, n)for i := 0; i < n; i++ {ret[i] = nextInt()}return ret}func nextFloats(n int) []float64 {ret := make([]float64, n)for i := 0; i < n; i++ {ret[i] = nextFloat()}return ret}func nextStrings(n int) []string {ret := make([]string, n)for i := 0; i < n; i++ {ret[i] = next()}return ret}func main() {sc.Split(bufio.ScanWords)var n, m = nextInt(), nextInt()var c = nextInts(n)sort.Ints(c)ans, remain := 0, mfor _, v := range c {if v > remain {break}remain = remain - vans++}fmt.Println(ans)}