結果

問題 No.60 魔法少女
ユーザー xuzijian629xuzijian629
提出日時 2018-11-03 02:22:22
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 198 ms / 5,000 ms
コード長 1,322 bytes
コンパイル時間 2,428 ms
コンパイル使用メモリ 203,984 KB
実行使用メモリ 11,076 KB
最終ジャッジ日時 2023-08-13 01:59:05
合計ジャッジ時間 5,628 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
10,892 KB
testcase_01 AC 11 ms
10,936 KB
testcase_02 AC 11 ms
10,992 KB
testcase_03 AC 11 ms
10,940 KB
testcase_04 AC 107 ms
11,076 KB
testcase_05 AC 120 ms
10,932 KB
testcase_06 AC 192 ms
10,940 KB
testcase_07 AC 143 ms
10,880 KB
testcase_08 AC 96 ms
10,924 KB
testcase_09 AC 47 ms
10,904 KB
testcase_10 AC 183 ms
10,960 KB
testcase_11 AC 28 ms
11,016 KB
testcase_12 AC 86 ms
10,888 KB
testcase_13 AC 198 ms
10,892 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

int main() {
    int n, k;
    cin >> n >> k;

    vvi b(1010, vi(1010));
    for (int i = 0; i < n; i++) {
        int x, y, h;
        cin >> x >> y >> h;
        x += 500;
        y += 500;
        b[x][y] += h;
        b[x + 1][y] -= h;
        b[x][y + 1] -= h;
        b[x + 1][y + 1] += h;
    }
    for (int i = 0; i < k; i++) {
        int x, y, h, w, d;
        cin >> x >> y >> h >> w >> d;
        x += 500;
        y += 500;
        b[x][y] -= d;
        if (x + h + 1 < 1010) {
            b[x + h + 1][y] += d;
        }
        if (y + w + 1 < 1010) {
            b[x][y + w + 1] += d;
        }
        if (x + h + 1 < 1010 && y + w + 1 < 1010) {
            b[x + h + 1][y + w + 1] -= d;
        } 
    }
    for (int i = 0; i < 1010; i++) {
        for (int j = 0; j < 1010 - 1; j++) {
            b[i][j + 1] += b[i][j];
        }
    }
    for (int i = 0; i < 1010 - 1; i++) {
        for (int j = 0; j < 1010; j++) {
            b[i + 1][j] += b[i][j];
        }
    }

    i64 cnt = 0;
    for (int i = 0; i < 1010; i++) {
        for (int j = 0; j < 1010; j++) {
            if (b[i][j] > 0) {
                cnt += b[i][j];
            }
        }
    }
    cout << cnt << endl;
}
0