結果

問題 No.60 魔法少女
ユーザー tubo28tubo28
提出日時 2014-11-10 00:12:16
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,467 bytes
コンパイル時間 473 ms
コンパイル使用メモリ 63,632 KB
実行使用メモリ 14,000 KB
最終ジャッジ日時 2023-08-30 02:55:06
合計ジャッジ時間 4,441 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
11,020 KB
testcase_01 AC 12 ms
11,000 KB
testcase_02 AC 11 ms
11,268 KB
testcase_03 WA -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
権限があれば一括ダウンロードができます

ソースコード

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 = 700;
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