結果

問題 No.60 魔法少女
ユーザー 🍮かんプリン🍮かんプリン
提出日時 2019-09-09 20:34:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 214 ms / 5,000 ms
コード長 1,198 bytes
コンパイル時間 1,926 ms
コンパイル使用メモリ 170,240 KB
実行使用メモリ 23,088 KB
最終ジャッジ日時 2023-09-11 00:00:14
合計ジャッジ時間 4,434 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
20,596 KB
testcase_01 AC 33 ms
20,664 KB
testcase_02 AC 32 ms
20,792 KB
testcase_03 AC 31 ms
20,676 KB
testcase_04 AC 129 ms
20,976 KB
testcase_05 AC 135 ms
22,784 KB
testcase_06 AC 209 ms
23,004 KB
testcase_07 AC 160 ms
22,252 KB
testcase_08 AC 113 ms
21,988 KB
testcase_09 AC 67 ms
21,124 KB
testcase_10 AC 198 ms
22,768 KB
testcase_11 AC 50 ms
21,164 KB
testcase_12 AC 103 ms
22,224 KB
testcase_13 AC 214 ms
23,088 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i,n,m) for(int i = (int)(n); i < int(m); i++)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = MOD - 1;
const ll LLINF = 4e18;

int main() {
    int n, k; cin >> n >> k;
    vector<vector<ll>> grid(1502, vector<ll>(1502,0));
    vector<ll> x(n),y(n),hp(n);
    REP(i, n) {
        cin >> x[i] >> y[i] >> hp[i];
    }
    REP(i, k) {
        int ax, ay, w, h, d; cin >> ax >> ay >> w >> h >> d;
        grid[ax + 500][ay + 500] -= d;
        grid[ax + w + 501][ay + h + 501] -= d;
        grid[ax + w + 501][ay + 500] += d;
        grid[ax + 500][ay + h + 501] += d;
    }
    REP(i, 1502) {
        FOR(j, 1, 1502) {
            grid[i][j] += grid[i][j - 1];
        }
    }
    REP(i, 1502) {
        FOR(j, 1, 1502) {
            grid[j][i] += grid[j - 1][i];
        }
    }
    ll ans = 0;
    REP(i, n) {
        ans += max(0LL, hp[i] + grid[x[i] + 500][y[i] + 500]);
    }
    cout << ans << endl;
    getchar(); getchar();
}
0