結果

問題 No.60 魔法少女
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2022-12-20 17:22:47
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 215 ms / 5,000 ms
コード長 1,108 bytes
コンパイル時間 4,486 ms
コンパイル使用メモリ 108,264 KB
実行使用メモリ 18,976 KB
最終ジャッジ日時 2023-08-11 10:21:45
合計ジャッジ時間 4,605 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
18,932 KB
testcase_01 AC 15 ms
18,892 KB
testcase_02 AC 14 ms
18,976 KB
testcase_03 AC 14 ms
18,956 KB
testcase_04 AC 118 ms
18,964 KB
testcase_05 AC 131 ms
18,920 KB
testcase_06 AC 207 ms
18,960 KB
testcase_07 AC 156 ms
18,892 KB
testcase_08 AC 104 ms
18,916 KB
testcase_09 AC 52 ms
18,928 KB
testcase_10 AC 198 ms
18,944 KB
testcase_11 AC 35 ms
18,956 KB
testcase_12 AC 95 ms
18,920 KB
testcase_13 AC 215 ms
18,924 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <numeric>
#include <deque>
#include <complex>

using namespace std;

int main(){

    long long N, K, ans=0, X, Y, W, H, D, P;
    cin >> N >> K;
    vector<vector<long long>> HP(1002, vector<long long>(1002)), DM(1002, vector<long long>(1002));
    for (int i=0; i<N; i++){
        cin >> X >> Y >> P;
        X += 501; Y += 501;
        HP[X][Y] += P;
    }

    
    for (int i=0; i<K; i++){
        cin >> X >> Y >> W >> H >> D;
        X += 501; Y += 501;
        DM[X][Y] += D;
        if (X+W+1 <= 1001) DM[X+W+1][Y] -= D;
        if (Y+H+1 <= 1001) DM[X][Y+H+1] -= D;
        if (X+W+1 <= 1001 && Y+H+1 <= 1001) DM[X+W+1][Y+H+1] += D;
    }

    for (int i=0; i<=1000; i++){
        for (int j=0; j<=1000; j++){
            DM[i+1][j+1] += DM[i+1][j] + DM[i][j+1] - DM[i][j];
        }
    }

    for (int i=0; i<=1001; i++){
        for (int j=0; j<=1001; j++) ans += max(0LL, HP[i][j] - DM[i][j]);
    }

    cout << ans << endl;

    return 0;
}
0