結果

問題 No.60 魔法少女
ユーザー izuru_matsuuraizuru_matsuura
提出日時 2016-09-29 21:17:31
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 270 ms / 5,000 ms
コード長 1,683 bytes
コンパイル時間 1,304 ms
コンパイル使用メモリ 168,488 KB
実行使用メモリ 22,244 KB
最終ジャッジ日時 2023-08-13 14:54:38
合計ジャッジ時間 4,540 ms
ジャッジサーバーID
(参考情報)
judge10 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
21,240 KB
testcase_01 AC 9 ms
21,248 KB
testcase_02 AC 8 ms
21,308 KB
testcase_03 AC 8 ms
21,184 KB
testcase_04 AC 177 ms
21,432 KB
testcase_05 AC 133 ms
22,116 KB
testcase_06 AC 264 ms
21,864 KB
testcase_07 AC 195 ms
21,652 KB
testcase_08 AC 119 ms
21,708 KB
testcase_09 AC 58 ms
21,484 KB
testcase_10 AC 240 ms
22,244 KB
testcase_11 AC 22 ms
21,476 KB
testcase_12 AC 91 ms
21,596 KB
testcase_13 AC 270 ms
22,128 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

namespace {

    typedef double real;
    typedef long long ll;

    template<class T> ostream& operator<<(ostream& os, const vector<T>& vs) {
        if (vs.empty()) return os << "[]";
        auto i = vs.begin();
        os << "[" << *i;
        for (++i; i != vs.end(); ++i) os << " " << *i;
        return os << "]";
    }
    template<class T> istream& operator>>(istream& is, vector<T>& vs) {
        for (auto it = vs.begin(); it != vs.end(); it++) is >> *it;
        return is;
    }

    int N, K;
    vector<int> X, Y, HP;
    void input() {
        cin >> N >> K;
        X.resize(N);
        Y.resize(N);
        HP.resize(N);
        for (int i = 0; i < N; i++) {
            cin >> X[i] >> Y[i] >> HP[i];
        }
    }

    const int M = 500;

    void solve() {
        static int S[1511][1511];
        static int D[1511][1511];
        memset(S, 0, sizeof(S));
        memset(D, 0, sizeof(D));
        for (int k = 0; k < K; k++) {
            int x, y, w, h, d; cin >> x >> y >> w >> h >> d;
            x += M; y += M;
            for (int y1 = y; y1 <= y + h; y1++) {
                D[y1][x] += d;
                D[y1][x + w + 1] -= d;
            }
        }
        for (int y = 0; y <= 1510; y++) {
            int d = 0;
            for (int x = 0; x <= 1510; x++) {
                d += D[y][x];
                S[y][x] = d;
            }
        }

        int ans = 0;
        for (int i = 0; i < N; i++) {
            int x = X[i] + M, y = Y[i] + M, hp = HP[i];
            ans += max(0, hp - S[y][x]);
        }
        cout << ans << endl;
    }
}

int main() {
    input(); solve();
    return 0;
}

0