結果

問題 No.60 魔法少女
ユーザー motumotumotumotu
提出日時 2014-11-10 14:16:38
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 181 ms / 5,000 ms
コード長 2,055 bytes
コンパイル時間 607 ms
コンパイル使用メモリ 76,812 KB
実行使用メモリ 8,060 KB
最終ジャッジ日時 2023-08-30 03:03:53
合計ジャッジ時間 2,891 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
7,528 KB
testcase_01 AC 9 ms
7,340 KB
testcase_02 AC 10 ms
7,424 KB
testcase_03 AC 10 ms
7,536 KB
testcase_04 AC 101 ms
7,620 KB
testcase_05 AC 108 ms
8,060 KB
testcase_06 AC 175 ms
8,048 KB
testcase_07 AC 131 ms
7,828 KB
testcase_08 AC 85 ms
7,752 KB
testcase_09 AC 41 ms
7,576 KB
testcase_10 AC 162 ms
8,004 KB
testcase_11 AC 25 ms
7,636 KB
testcase_12 AC 76 ms
7,808 KB
testcase_13 AC 181 ms
8,044 KB
権限があれば一括ダウンロードができます

ソースコード

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