結果
| 問題 | No.60 魔法少女 | 
| コンテスト | |
| ユーザー |  Kutimoti_T | 
| 提出日時 | 2018-01-10 23:55:01 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 184 ms / 5,000 ms | 
| コード長 | 1,091 bytes | 
| コンパイル時間 | 540 ms | 
| コンパイル使用メモリ | 68,004 KB | 
| 実行使用メモリ | 24,432 KB | 
| 最終ジャッジ日時 | 2024-12-23 17:08:52 | 
| 合計ジャッジ時間 | 2,466 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 10 | 
ソースコード
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define FOR(i, s, e) for (int i = (s); i <= (e); i++)
typedef long long ll;
ll N;
ll K;
int X[100000],Y[100000],HP[100000];
ll imos[1600][1600];
int main()
{
    cin >> N >> K;
    FOR(i,0,N - 1)
    {
        cin >> X[i] >> Y[i] >> HP[i];
        X[i] += 500;
        Y[i] += 500;
    }
    int ax,ay,w,h,d;
    FOR(i,0,K - 1)
    {
        cin >> ax >> ay >> w >> h >> d;
        ax += 500;
        ay += 500;
        imos[ax][ay] += d;
        imos[ax][ay + h + 1] += -d;
        imos[ax + w + 1][ay] += -d;
        imos[ax + w + 1][ay + h + 1] += d;
    }
    FOR(i,0,1000)
    {
        FOR(j,0,1000)
        {
            imos[i][j + 1] += imos[i][j];
        }
    }
    FOR(j,0,1000)
    {
        FOR(i,0,1000)
        {
            imos[i + 1][j] += imos[i][j];
        }
    }
    ll result = 0;
    FOR(i,0,N - 1)
    {
        result += max(0LL,HP[i] - imos[X[i]][Y[i]]);
    }
    cout << result << endl;
    return 0;
}
            
            
            
        