結果

問題 No.60 魔法少女
ユーザー ixTL255ixTL255
提出日時 2023-01-10 23:46:13
言語 Rust
(1.77.0)
結果
AC  
実行時間 48 ms / 5,000 ms
コード長 1,746 bytes
コンパイル時間 1,241 ms
コンパイル使用メモリ 156,216 KB
実行使用メモリ 21,060 KB
最終ジャッジ日時 2023-08-23 10:34:13
合計ジャッジ時間 3,683 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
9,912 KB
testcase_01 AC 10 ms
9,880 KB
testcase_02 AC 11 ms
9,892 KB
testcase_03 AC 10 ms
9,848 KB
testcase_04 AC 31 ms
15,248 KB
testcase_05 AC 32 ms
15,516 KB
testcase_06 AC 47 ms
19,880 KB
testcase_07 AC 39 ms
18,272 KB
testcase_08 AC 28 ms
14,652 KB
testcase_09 AC 18 ms
12,120 KB
testcase_10 AC 45 ms
19,668 KB
testcase_11 AC 14 ms
10,908 KB
testcase_12 AC 27 ms
14,300 KB
testcase_13 AC 48 ms
21,060 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: constant `m` should have an upper case name
 --> Main.rs:4:11
  |
4 |     const m: usize = 1002;
  |           ^ help: convert the identifier to upper case: `M`
  |
  = note: `#[warn(non_upper_case_globals)]` on by default

warning: constant `offset` should have an upper case name
 --> Main.rs:5:11
  |
5 |     const offset: isize = 500;
  |           ^^^^^^ help: convert the identifier to upper case: `OFFSET`

warning: 2 warnings emitted

ソースコード

diff #

use std::io::*;

fn main() {
    const m: usize = 1002;
    const offset: isize = 500;
    let mut stg = vec![vec![0; m]; m];

    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();

    let n: usize = itr.next().unwrap().parse().unwrap();
    let k: usize = itr.next().unwrap().parse().unwrap();
    
    let mut mons = Vec::<(isize, isize, isize)>::new();
    for _ in 0..n {
        mons.push((
            itr.next().unwrap().parse().unwrap(),
            itr.next().unwrap().parse().unwrap(),
            itr.next().unwrap().parse().unwrap()
            ));
    } 

    let mut att = Vec::<(isize, isize, usize, usize, isize)>::new();
    for _ in 0..k {
        att.push((
            itr.next().unwrap().parse().unwrap(),
            itr.next().unwrap().parse().unwrap(),
            itr.next().unwrap().parse().unwrap(),
            itr.next().unwrap().parse().unwrap(),
            itr.next().unwrap().parse().unwrap(),
            ));
    }

    for t in att {
        let x = (t.0 + offset) as usize;
        let y = (t.1 + offset) as usize;
        let xw = std::cmp::min(x + t.2 + 1, m - 1);
        let yh = std::cmp::min(y + t.3 + 1, m - 1);
        let d = t.4;
        stg[x][y] += d;
        stg[xw][y] -= d;
        stg[x][yh] -= d;
        stg[xw][yh] += d;
    }

    for i in 0..m {
        for j in 1..m { stg[i][j] += stg[i][j - 1]; }
    }

    for i in 1..m {
        for j in 0..m { stg[i][j] += stg[i - 1][j]; }
    }

    let mut ans = 0;
    for t in mons {
        let x = (t.0 + offset) as usize;
        let y = (t.1 + offset) as usize;
        let h = t.2;
        ans += std::cmp::max(h - stg[x][y], 0);
    }

    println!("{}", ans);

}
0