#![allow(dead_code, unused_variables)] use std::io::{stdin, BufRead}; fn main() { let v = veci32_from_line(); let n = v[0]; let k = v[1]; let mut a = veci32_from_line(); a.sort(); let mut ground = 0; let mut rest = k; for i in a.iter() { if i >= &rest { break; } rest -= i; ground += 1; } println!("{} {}", ground, rest); } fn get_line() -> String { let mut buf = String::new(); stdin().lock().read_line(&mut buf).unwrap(); buf.trim_end().to_string() } fn veci32_from_line() -> Vec { get_line() .split_whitespace() .map(|s| s.parse().unwrap()) .collect() }