結果

問題 No.60 魔法少女
ユーザー tubo28tubo28
提出日時 2014-11-10 00:34:14
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 192 ms / 5,000 ms
コード長 1,471 bytes
コンパイル時間 648 ms
コンパイル使用メモリ 63,244 KB
実行使用メモリ 25,184 KB
最終ジャッジ日時 2023-08-30 02:58:05
合計ジャッジ時間 2,888 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 21 ms
22,280 KB
testcase_01 AC 21 ms
22,392 KB
testcase_02 AC 22 ms
22,268 KB
testcase_03 AC 22 ms
22,272 KB
testcase_04 AC 111 ms
23,612 KB
testcase_05 AC 119 ms
23,496 KB
testcase_06 AC 185 ms
24,820 KB
testcase_07 AC 140 ms
24,152 KB
testcase_08 AC 97 ms
23,360 KB
testcase_09 AC 53 ms
22,496 KB
testcase_10 AC 177 ms
24,688 KB
testcase_11 AC 37 ms
22,292 KB
testcase_12 AC 89 ms
22,976 KB
testcase_13 AC 192 ms
25,184 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