結果

問題 No.60 魔法少女
ユーザー motumotu
提出日時 2014-11-10 14:16:38
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 201 ms / 5,000 ms
コード長 2,055 bytes
コンパイル時間 847 ms
コンパイル使用メモリ 83,272 KB
実行使用メモリ 8,548 KB
最終ジャッジ日時 2024-12-31 09:27:20
合計ジャッジ時間 3,419 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <sstream>
#include <functional>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define CLEAR(d) memset((d), 0, (sizeof((d))))
#define ALL(c) (c).begin(), (c).end()
#define SORT(x) sort((x).begin(), (x).end())
#define RSORT(x) sort((x).begin(), (x).end(), greater<int>() )
#define SIZE(a) ((int)((a).size()))
#define MAX3(a, b, c) (max(max((a), (b)), (c)))
#define MIN3(a, b, c) (min(min((a), (b)), (c)))
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define EPS 1e-5
#define PI  (acos(-1))
#define INF 10000000
struct edge{ int to, cost; };
//===================================================

int damage[1001][1001];

int main()
{
    int n, k, ax, ay, w, h, d, sum = 0;
    cin >> n >> k;
    vector<int> x(n), y(n), hp(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i] >> hp[i];
    }
    for (int i = 0; i < k; i++) {
        cin >> ax >> ay >> w >> h >> d;
        ax += 500, ay += 500;
        damage[ay][ax] += d;
        if (ay + h + 1 <= 1000) { damage[ay + h + 1][ax] -= d; }
        if (ax + w + 1 <= 1000) { damage[ay][ax + w + 1] -= d; }
        if (ay + h + 1 <= 1000 && ax + w + 1 <= 1000) { damage[ay + h + 1][ax + w + 1] += d; }
    }
    for (int y = 0; y <= 1000; y++) {
        for (int x = 1; x <= 1000; x++) {
            damage[y][x] += damage[y][x - 1];
        }
    }
    for (int x = 0; x <= 1000; x++) {
        for (int y = 1; y <= 1000; y++) {
            damage[y][x] += damage[y - 1][x];
        }
    }
    for (int i = 0; i < n; i++) {
        int h = hp[i] - damage[y[i] + 500][x[i] + 500];
        sum += (h >= 0) ? h : 0;
    }
    printf("%d\n", sum);
    return 0;
}
0