結果
問題 | No.2424 Josouzai |
ユーザー |
|
提出日時 | 2024-05-23 00:02:48 |
言語 | Go (1.23.4) |
結果 |
AC
|
実行時間 | 43 ms / 2,000 ms |
コード長 | 986 bytes |
コンパイル時間 | 11,767 ms |
コンパイル使用メモリ | 228,012 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-20 18:42:37 |
合計ジャッジ時間 | 14,204 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 33 |
ソースコード
// No.2424 Josouzaipackage 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, k int = nextInt(), nextInt()var a = nextInts(n)sort.Ints(a)var ans1, ans2 = 0, kfor j := 0; j < n; j++ {if ans2-a[j] < 0 {break}ans2 -= a[j]ans1++}fmt.Printf("%d %d\n", ans1, ans2)}