結果

問題 No.2424 Josouzai
ユーザー ゆうPゆうP
提出日時 2024-05-23 00:02:48
言語 Go
(1.22.1)
結果
AC  
実行時間 40 ms / 2,000 ms
コード長 986 bytes
コンパイル時間 11,643 ms
コンパイル使用メモリ 227,260 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-23 00:03:03
合計ジャッジ時間 14,123 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 1 ms
6,820 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 12 ms
6,944 KB
testcase_05 AC 40 ms
6,940 KB
testcase_06 AC 39 ms
6,944 KB
testcase_07 AC 39 ms
6,944 KB
testcase_08 AC 40 ms
6,940 KB
testcase_09 AC 1 ms
6,944 KB
testcase_10 AC 6 ms
6,944 KB
testcase_11 AC 16 ms
6,940 KB
testcase_12 AC 12 ms
6,944 KB
testcase_13 AC 12 ms
6,940 KB
testcase_14 AC 22 ms
6,940 KB
testcase_15 AC 4 ms
6,940 KB
testcase_16 AC 34 ms
6,940 KB
testcase_17 AC 9 ms
6,940 KB
testcase_18 AC 11 ms
6,944 KB
testcase_19 AC 19 ms
6,940 KB
testcase_20 AC 35 ms
6,944 KB
testcase_21 AC 27 ms
6,940 KB
testcase_22 AC 13 ms
6,944 KB
testcase_23 AC 15 ms
6,944 KB
testcase_24 AC 7 ms
6,944 KB
testcase_25 AC 37 ms
6,940 KB
testcase_26 AC 26 ms
6,944 KB
testcase_27 AC 38 ms
6,944 KB
testcase_28 AC 33 ms
6,944 KB
testcase_29 AC 29 ms
6,940 KB
testcase_30 AC 7 ms
6,940 KB
testcase_31 AC 17 ms
6,940 KB
testcase_32 AC 37 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// No.2424 Josouzai
package main

import (
	"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, k int = nextInt(), nextInt()
	var a = nextInts(n)
	sort.Ints(a)

	var ans1, ans2 = 0, k
	for j := 0; j < n; j++ {
		if ans2-a[j] < 0 {
			break
		}
		ans2 -= a[j]
		ans1++
	}
	fmt.Printf("%d %d\n", ans1, ans2)
}
0