結果

問題 No.60 魔法少女
ユーザー ynpppynppp
提出日時 2024-03-26 10:36:11
言語 Rust
(1.77.0)
結果
AC  
実行時間 152 ms / 5,000 ms
コード長 2,769 bytes
コンパイル時間 1,420 ms
コンパイル使用メモリ 189,776 KB
実行使用メモリ 20,736 KB
最終ジャッジ日時 2024-03-26 10:36:24
合計ジャッジ時間 4,711 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
17,536 KB
testcase_01 AC 57 ms
17,536 KB
testcase_02 AC 57 ms
17,536 KB
testcase_03 AC 57 ms
17,536 KB
testcase_04 AC 96 ms
19,200 KB
testcase_05 AC 100 ms
19,328 KB
testcase_06 AC 130 ms
20,608 KB
testcase_07 AC 110 ms
19,712 KB
testcase_08 AC 91 ms
18,944 KB
testcase_09 AC 73 ms
18,176 KB
testcase_10 AC 152 ms
20,352 KB
testcase_11 AC 65 ms
17,792 KB
testcase_12 AC 88 ms
18,816 KB
testcase_13 AC 133 ms
20,736 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#![allow(dead_code, unused_variables, unused_macros, unused_imports)]

fn main() {
    input!(n:usize,k:usize, xyhp:[(i32,i32,i32);n],xywhd:[(i32,i32,i32,i32,i32);k]);
    let mut v = vec![vec![0; 2000]; 2000];
    const INFLATE: i32 = 500;
    for (x, y, w, h, d) in xywhd {
        v[(y + INFLATE) as usize][(x + INFLATE) as usize] += d;
        v[(y + INFLATE + h + 1) as usize][(x + INFLATE) as usize] -= d;
        v[(y + INFLATE) as usize][(x + INFLATE + w + 1) as usize] -= d;
        v[(y + INFLATE + h + 1) as usize][(x + INFLATE + w + 1) as usize] += d;
    }
    for y in 0..v.len() {
        for x in 1..v[y].len() {
            v[y][x] += v[y][x - 1];
        }
    }
    for x in 0..v[0].len() {
        for y in 1..v.len() {
            v[y][x] += v[y - 1][x];
        }
    }
    let mut ans = 0;
    for (x, y, hp) in xyhp {
        let d = v[(y + INFLATE) as usize][(x + INFLATE) as usize];
        if d >= 0 {
            ans += 0.max(hp - d);
        }
    }
    println!("{}", ans);
}

mod xxx {
    // https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
    #[macro_export]
    macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        input_inner!{$s, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
    #[macro_export]
    macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

    #[macro_export]
    macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, bits)=>{
        u64::from_str_radix(&$next(), 2).expect("Parse error")
    };

    ($next:expr, hexs)=>{
        u64::from_str_radix(&$next(), 16).expect("Parse error")
    };


    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
}
0