結果

問題 No.60 魔法少女
ユーザー prtoq3prtoq3
提出日時 2018-10-15 00:29:33
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 1,207 bytes
コンパイル時間 1,376 ms
コンパイル使用メモリ 159,796 KB
実行使用メモリ 21,248 KB
最終ジャッジ日時 2024-04-20 20:22:12
合計ジャッジ時間 5,073 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
21,248 KB
testcase_01 AC 19 ms
21,132 KB
testcase_02 AC 17 ms
21,216 KB
testcase_03 AC 17 ms
21,248 KB
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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

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

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 < MAX_N; i++){
        for (int j = 1; j < MAX_N; j++){
            table[i][j] += table[i][j - 1];
        }
    }

    // 縦方向への累積和
    for (int i = 1; i < MAX_N; i++){
        for (int j = 0; j < MAX_N; 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