結果

問題 No.60 魔法少女
ユーザー tubo28
提出日時 2014-11-10 00:03:25
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
RE  
実行時間 -
コード長 1,823 bytes
コンパイル時間 936 ms
コンパイル使用メモリ 67,716 KB
実行使用メモリ 21,888 KB
最終ジャッジ日時 2024-12-31 09:06:44
合計ジャッジ時間 4,235 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 6 RE * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

#define loop(i,a,b) for(int i=(a);i<int(b);i++)
#define rep(i,b) loop(i,0,b)

typedef vector<int> vi;
typedef vector<vi> vvi;

struct Enemy {
    int x,y,h;
};

struct Magic {
    int x,y,w,h,d;
};

int const GETA = 1000;

int main(){
    int N,K;
    while(cin>>N>>K){
        vector<Enemy> es(N);
        for(auto &e : es){
            cin >> e.x >> e.y >> e.h;
            e.x+=GETA, e.y+=GETA;
        }

        vector<Magic> ms(K);
        for(auto &m : ms){
            cin>> m.x >> m.y >> m.w >> m.h >> m.d;
            m.x+=GETA, m.y+=GETA;
            m.w++;m.h++;
        }

        vvi imos(GETA*2,vi(GETA*2));
        for(auto &m: ms){
            imos[m.y][m.x]+=m.d;
            imos[min(GETA*2, m.y+m.h)][m.x]-=m.d;
            imos[m.y][min(GETA*2, m.x+m.w)]-=m.d;
            imos[min(GETA*2, m.y+m.h)][min(GETA*2, m.x+m.w)]+=m.d;
        }

        for(int i=0;i<imos.size();i++){
            for(int j=1;j<imos[0].size();j++){
                imos[i][j] += imos[i][j-1];
            }
        }
        for(int i=1;i<imos.size();i++){
            for(int j=0;j<imos[0].size();j++){
                imos[i][j] += imos[i-1][j];
            }
        }

        // for(int i=-5+GETA;i<5+GETA;i++){
        //     for(int j=-5+GETA;j<5+GETA;j++){
        //         cout << imos[i][j] << " ";
        //         // cout << i << " " << j << endl;
        //     }
        //     cout << endl;
        // }

        int ans=0;
        for(auto &e : es){
            // cout << e.y << " " << e.x << " " << e.h << endl;
            // cout << imos[e.y][e.x] << endl;
            ans += max(0,e.h-imos[e.y][e.x]);
        }
        cout << ans << endl;
    }
}
0