Submission #2973542

Source Code Expand

Copy
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn solve(n:i32, total:i32) -> (i32,i32,i32) {
    for i in 0..n+1 {
        for j in 0..n-i+1 {
            let k = n - i - j;
            if 10000*i + 5000*j + 1000*k == total {
                return (i, j, k);
            }
        }
    }
    (-1, -1, -1)
}
fn main() {
    let ny = read_vec::<i32>();
    let (x,y,z) = solve(ny[0], ny[1]);
    println!("{} {} {}", x, y, z);
}

Submission Info

Submission Time
Task ABC085C - Otoshidama
User naoya_t
Language Rust (1.15.1)
Score 300
Code Size 701 Byte
Status
Exec Time 5 ms
Memory 4352 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 a01, a02, a03, a04
All 300 / 300 a01, a02, a03, a04, b05, b06, b07, b08, b09, b10, b11, b12, b13, b14, b15, b16, b17, b18, b19, b20, b21, b22, b23, b24
Case Name Status Exec Time Memory
a01 2 ms 4352 KB
a02 2 ms 4352 KB
a03 2 ms 4352 KB
a04 5 ms 4352 KB
b05 2 ms 4352 KB
b06 2 ms 4352 KB
b07 2 ms 4352 KB
b08 2 ms 4352 KB
b09 5 ms 4352 KB
b10 5 ms 4352 KB
b11 5 ms 4352 KB
b12 2 ms 4352 KB
b13 2 ms 4352 KB
b14 2 ms 4352 KB
b15 5 ms 4352 KB
b16 4 ms 4352 KB
b17 5 ms 4352 KB
b18 2 ms 4352 KB
b19 2 ms 4352 KB
b20 2 ms 4352 KB
b21 5 ms 4352 KB
b22 5 ms 4352 KB
b23 5 ms 4352 KB
b24 4 ms 4352 KB