結果

問題 No.60 魔法少女
ユーザー tubo28tubo28
提出日時 2014-11-10 00:13:23
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 190 ms / 5,000 ms
コード長 1,468 bytes
コンパイル時間 489 ms
コンパイル使用メモリ 62,880 KB
実行使用メモリ 24,996 KB
最終ジャッジ日時 2023-08-30 02:56:08
合計ジャッジ時間 2,764 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 21 ms
22,248 KB
testcase_01 AC 22 ms
22,220 KB
testcase_02 AC 22 ms
22,256 KB
testcase_03 AC 22 ms
22,364 KB
testcase_04 AC 110 ms
23,712 KB
testcase_05 AC 117 ms
23,672 KB
testcase_06 AC 182 ms
24,996 KB
testcase_07 AC 140 ms
24,108 KB
testcase_08 AC 98 ms
23,472 KB
testcase_09 AC 52 ms
22,620 KB
testcase_10 AC 174 ms
24,764 KB
testcase_11 AC 38 ms
22,284 KB
testcase_12 AC 88 ms
23,048 KB
testcase_13 AC 190 ms
24,896 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
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 = 1100;
int const SZ=GETA*2;
int imos[SZ][SZ];

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++;
        }

        memset(imos,0,sizeof(imos));
        for(auto &m: ms){
            imos[m.y][m.x]+=m.d;
            imos[min(SZ, m.y+m.h)][m.x]-=m.d;
            imos[m.y][min(SZ, m.x+m.w)]-=m.d;
            imos[min(SZ, m.y+m.h)][min(SZ, m.x+m.w)]+=m.d;
        }

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

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