結果

問題 No.1490 スライムと爆弾
ユーザー merom686merom686
提出日時 2021-04-24 00:10:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 116 ms / 2,000 ms
コード長 1,443 bytes
コンパイル時間 2,061 ms
コンパイル使用メモリ 203,568 KB
実行使用メモリ 36,412 KB
最終ジャッジ日時 2023-09-17 13:16:18
合計ジャッジ時間 4,542 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 53 ms
24,080 KB
testcase_14 AC 64 ms
29,484 KB
testcase_15 AC 38 ms
27,844 KB
testcase_16 AC 45 ms
22,264 KB
testcase_17 AC 30 ms
21,968 KB
testcase_18 AC 62 ms
25,168 KB
testcase_19 AC 58 ms
32,848 KB
testcase_20 AC 44 ms
29,956 KB
testcase_21 AC 30 ms
29,616 KB
testcase_22 AC 53 ms
24,612 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 75 ms
36,412 KB
testcase_26 AC 75 ms
36,328 KB
testcase_27 AC 75 ms
36,396 KB
testcase_28 AC 65 ms
34,840 KB
testcase_29 AC 67 ms
34,936 KB
testcase_30 AC 116 ms
36,408 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using ll = long long;
using namespace std;

ll s[2001][2001];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int h, w, n, m;
    cin >> h >> w >> n >> m;

    vector<array<int, 5>> p(n);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 5; j++) {
            cin >> p[i][j];
        }
    }

    for (int i = 0; i < m; i++) {
        int x, y, b, c;
        cin >> x >> y >> b >> c;
        int t = max(x - b - 1, 0);
        int u = min(x + b, h);
        int l = max(y - b - 1, 0);
        int r = min(y + b, w);

        s[t][l] += c;
        s[t][r] -= c;
        s[u][l] -= c;
        s[u][r] += c;
    }
    for (int _ = 0; _ < 2; _++) {
        for (int i = 1; i < h; i++) {
            for (int j = 0; j < w; j++) {
                s[i][j] += s[i - 1][j];
            }
        }
        for (int i = 0; i < h; i++) {
            for (int j = 1; j < w; j++) {
                s[i][j] += s[i][j - 1];
            }
        }
    }

    for (int i = h; --i >= 0;) {
        for (int j = w; --j >= 0;) {
            s[i + 1][j + 1] = s[i][j];
        }
    }
    for (int i = 0; i <= h; i++) {
        s[i][0] = 0;
    }
    for (int j = 0; j <= w; j++) {
        s[0][j] = 0;
    }

    int ans = 0;
    for (auto [t, u, l, r, a] : p) {
        t--; l--;
        ll c = s[u][r] - s[u][l] - s[t][r] + s[t][l];
        ans += c < a;
    }

    cout << ans << endl;

    return 0;
}
0