結果

問題 No.60 魔法少女
ユーザー tubo28tubo28
提出日時 2014-11-10 00:03:25
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 1,823 bytes
コンパイル時間 713 ms
コンパイル使用メモリ 68,524 KB
実行使用メモリ 22,276 KB
最終ジャッジ日時 2023-08-30 02:53:47
合計ジャッジ時間 3,928 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
18,612 KB
testcase_01 AC 25 ms
19,156 KB
testcase_02 AC 26 ms
18,704 KB
testcase_03 AC 26 ms
18,588 KB
testcase_04 AC 116 ms
20,420 KB
testcase_05 AC 123 ms
20,584 KB
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 AC 58 ms
19,364 KB
testcase_10 AC 178 ms
21,512 KB
testcase_11 AC 42 ms
19,136 KB
testcase_12 AC 94 ms
19,908 KB
testcase_13 RE -
権限があれば一括ダウンロードができます

ソースコード

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