結果

問題 No.60 魔法少女
ユーザー kimiyukikimiyuki
提出日時 2016-09-29 21:39:55
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 76 ms / 5,000 ms
コード長 1,107 bytes
コンパイル時間 470 ms
コンパイル使用メモリ 49,584 KB
実行使用メモリ 13,504 KB
最終ジャッジ日時 2023-08-13 14:54:54
合計ジャッジ時間 1,885 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
10,824 KB
testcase_01 AC 7 ms
10,840 KB
testcase_02 AC 6 ms
10,828 KB
testcase_03 AC 7 ms
10,852 KB
testcase_04 AC 45 ms
12,024 KB
testcase_05 AC 47 ms
12,312 KB
testcase_06 AC 74 ms
13,504 KB
testcase_07 AC 56 ms
12,640 KB
testcase_08 AC 38 ms
11,864 KB
testcase_09 AC 21 ms
11,368 KB
testcase_10 AC 69 ms
13,104 KB
testcase_11 AC 14 ms
11,108 KB
testcase_12 AC 36 ms
11,656 KB
testcase_13 AC 76 ms
13,420 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <vector>
#include <array>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
typedef long long ll;
using namespace std;
const int size   = 1001;
const int offset = 500;
int main() {
    int n, k; scanf("%d%d", &n, &k);
    vector<int> x(n), y(n), hp(n); repeat (i,n) scanf("%d%d%d", &x[i], &y[i], &hp[i]);
    vector<int> ax(k), ay(k), w(k), h(k), d(k); repeat (i,k) scanf("%d%d%d%d%d", &ax[i], &ay[i], &w[i], &h[i], &d[i]);
    array<array<ll,size+1>,size+1> imos = {};
    repeat (i,k) {
        int lx = ax[i] + offset;
        int ly = ay[i] + offset;
        int rx = min(size, ax[i] + offset + w[i] + 1);
        int ry = min(size, ay[i] + offset + h[i] + 1);
        imos[ly][lx] += d[i];
        imos[ly][rx] -= d[i];
        imos[ry][lx] -= d[i];
        imos[ry][rx] += d[i];
    }
    repeat (y,size+1) repeat (x,size) imos[y][x+1] += imos[y][x];
    repeat (x,size+1) repeat (y,size) imos[y+1][x] += imos[y][x];
    ll ans = 0;
    repeat (i,n) {
        ans += max(0ll, hp[i] - imos[y[i] + offset][x[i] + offset]);
    }
    printf("%lld\n", ans);
    return 0;
}
0