Skip to content

Instantly share code, notes, and snippets.

@icub3d
Created December 21, 2025 20:48
Show Gist options
  • Select an option

  • Save icub3d/1f874f41996c5bd86dc5d62bb2012623 to your computer and use it in GitHub Desktop.

Select an option

Save icub3d/1f874f41996c5bd86dc5d62bb2012623 to your computer and use it in GitHub Desktop.
Kattis jobexpenses
use std::io::{Read, stdin};
fn main() {
let mut s = String::new();
stdin().read_to_string(&mut s).unwrap();
for m in s.lines().skip(1) {
let v = m
.split_whitespace()
.map(|v| v.parse::<isize>().unwrap())
.filter(|v| *v < 0)
.map(|v| v.abs())
.sum::<isize>();
println!("{v}");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment