結果
| 問題 | No.60 魔法少女 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2015-01-15 23:15:55 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 201 ms / 5,000 ms | 
| コード長 | 1,357 bytes | 
| コンパイル時間 | 999 ms | 
| コンパイル使用メモリ | 96,612 KB | 
| 実行使用メモリ | 8,320 KB | 
| 最終ジャッジ日時 | 2024-06-22 11:48:04 | 
| 合計ジャッジ時間 | 3,609 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 10 | 
ソースコード
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;
int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> ax(n), ay(n), hp(n);
    for(int i=0; i<n; ++i)
        cin >> ax[i] >> ay[i] >> hp[i];
    vector<vector<int> > mat(1002, vector<int>(1002, 0));
    while(--k >= 0){
        int x, y, w, h, d;
        cin >> x >> y >> w >> h >> d;
        int x1 = x + 500;
        int y1 = y + 500;
        int x2 = min(1000, x1 + w) + 1;
        int y2 = min(1000, y1 + h) + 1;
        mat[y1][x1] += d;
        mat[y1][x2] -= d;
        mat[y2][x1] -= d;
        mat[y2][x2] += d;
    }
    for(int y=0; y<1002; ++y){
        for(int x=1; x<1002; ++x){
            mat[y][x] += mat[y][x-1];
        }
    }
    for(int x=0; x<1002; ++x){
        for(int y=1; y<1002; ++y){
            mat[y][x] += mat[y-1][x];
        }
    }
    int ret = 0;
    for(int i=0; i<n; ++i){
        int x = ax[i] + 500;
        int y = ay[i] + 500;
        ret += max(0, hp[i] - mat[y][x]);
    }
    cout << ret << endl;
    return 0;
}
            
            
            
        