結果

問題 No.1490 スライムと爆弾
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2023-07-28 10:24:26
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 274 ms / 2,000 ms
コード長 1,163 bytes
コンパイル時間 2,099 ms
コンパイル使用メモリ 200,252 KB
実行使用メモリ 38,656 KB
最終ジャッジ日時 2024-04-15 19:23:14
合計ジャッジ時間 6,332 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 120 ms
18,560 KB
testcase_14 AC 149 ms
24,576 KB
testcase_15 AC 73 ms
19,328 KB
testcase_16 AC 108 ms
14,336 KB
testcase_17 AC 61 ms
22,144 KB
testcase_18 AC 144 ms
24,576 KB
testcase_19 AC 127 ms
22,528 KB
testcase_20 AC 94 ms
18,432 KB
testcase_21 AC 55 ms
17,280 KB
testcase_22 AC 131 ms
16,512 KB
testcase_23 AC 1 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 172 ms
38,656 KB
testcase_26 AC 176 ms
38,528 KB
testcase_27 AC 173 ms
38,528 KB
testcase_28 AC 128 ms
34,560 KB
testcase_29 AC 131 ms
34,560 KB
testcase_30 AC 274 ms
38,656 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main(){

    ll H, W, ans=0, N, M, X, Y, B, C;
    cin >> H >> W >> N >> M;
    vector<ll> T(N), U(N), L(N), R(N), A(N);
    for (int i=0; i<N; i++) cin >> T[i] >> U[i] >> L[i] >> R[i] >> A[i];
    vector<vector<ll>> D(H+2, vector<ll>(W+2));
    for (int i=0; i<M; i++){
        cin >> X >> Y >> B >> C;
        ll a, b, c, d;
        a = max(0LL, X-B);
        b = min(H+1, X+B+1);
        c = max(0LL, Y-B);
        d = min(W+1, Y+B+1);
        D[a][c] += C;
        D[a][d] -= C;
        D[b][c] -= C;
        D[b][d] += C;
    }

    for (int i=1; i<=H; i++){
        for (int j=0; j<=W; j++){
            D[i][j] += D[i-1][j];
        }
    }

    for (int i=0; i<=H; i++){
        for (int j=1; j<=W; j++){
            D[i][j] += D[i][j-1];
        }
    }

    for (int i=1; i<=H; i++){
        for (int j=1; j<=W; j++){
            D[i][j] += D[i-1][j] + D[i][j-1] - D[i-1][j-1];
        }
    }

    for (int i=0; i<N; i++){
        ll a=T[i]-1, b=U[i], c=L[i]-1, d=R[i];
        if (D[b][d]-D[b][c]-D[a][d]+D[a][c] < A[i]) ans++;
    }

    cout << ans << endl;

    return 0;
}
0