結果

問題 No.60 魔法少女
ユーザー prtoq3prtoq3
提出日時 2018-10-15 00:34:52
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 216 ms / 5,000 ms
コード長 1,203 bytes
コンパイル時間 1,546 ms
コンパイル使用メモリ 158,312 KB
実行使用メモリ 24,560 KB
最終ジャッジ日時 2024-04-20 20:22:16
合計ジャッジ時間 3,803 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
23,424 KB
testcase_01 AC 18 ms
23,424 KB
testcase_02 AC 19 ms
23,296 KB
testcase_03 AC 19 ms
23,424 KB
testcase_04 AC 129 ms
23,552 KB
testcase_05 AC 135 ms
24,536 KB
testcase_06 AC 211 ms
24,448 KB
testcase_07 AC 161 ms
24,184 KB
testcase_08 AC 109 ms
24,064 KB
testcase_09 AC 56 ms
23,680 KB
testcase_10 AC 203 ms
24,560 KB
testcase_11 AC 36 ms
23,700 KB
testcase_12 AC 93 ms
24,192 KB
testcase_13 AC 216 ms
24,456 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const int MAX_N = 100010;

#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)

int x[MAX_N], y[MAX_N], hp[MAX_N];
ll table[1600][1600];

int main(){
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; i++){
        cin >> x[i] >> y[i] >> hp[i];
        x[i] += 500;
        y[i] += 500;
    }

    for (int i = 0; i < k; i++){
        int Ax, Ay, w, h, d;
        cin >> Ax >> Ay >> w >> h >> d;
        Ax += 500;
        Ay += 500;
        table[Ay][Ax] += d;
        table[Ay + h + 1][Ax] -= d;
        table[Ay][Ax + w + 1] -= d;
        table[Ay + h + 1][Ax + w + 1] += d;
    }

    // 横方向への累積和
    for (int i = 0; i < 1600; i++){
        for (int j = 1; j < 1600; j++){
            table[i][j] += table[i][j - 1];
        }
    }

    // 縦方向への累積和
    for (int i = 1; i < 1600; i++){
        for (int j = 0; j < 1600; j++){
            table[i][j] += table[i - 1][j];
        }
    }

    ll ans = 0;
    for (int i = 0; i < n; i++){
        ll rest = hp[i] - table[y[i]][x[i]];
        if (rest > 0) ans += rest;
    }    

    cout << ans << endl;

    return 0;
}
0