結果

問題 No.60 魔法少女
ユーザー krotonkroton
提出日時 2014-11-09 21:12:48
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 202 ms / 5,000 ms
コード長 1,439 bytes
コンパイル時間 525 ms
コンパイル使用メモリ 53,136 KB
実行使用メモリ 19,960 KB
最終ジャッジ日時 2023-08-30 02:48:29
合計ジャッジ時間 3,503 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
15,636 KB
testcase_01 AC 25 ms
15,612 KB
testcase_02 AC 25 ms
15,828 KB
testcase_03 AC 22 ms
19,660 KB
testcase_04 AC 115 ms
19,960 KB
testcase_05 AC 123 ms
19,664 KB
testcase_06 AC 193 ms
19,752 KB
testcase_07 AC 148 ms
19,716 KB
testcase_08 AC 102 ms
19,740 KB
testcase_09 AC 56 ms
19,660 KB
testcase_10 AC 186 ms
19,796 KB
testcase_11 AC 38 ms
19,660 KB
testcase_12 AC 92 ms
19,664 KB
testcase_13 AC 202 ms
19,724 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;
void rc(int v,int mn,int mx){if(v<mn||mx<v){cerr<<"error"<<endl;exit(1);}}

const int OFFSET = 500;
const int SIZE = 1555;
int h[SIZE][SIZE];
int d[SIZE][SIZE];

int main(){
    int N, K;
    cin >> N >> K;

    rc(N, 1, 100000);
    rc(K, 1, 100000);
    
    for(int i=0;i<N;i++){
        int X, Y, H;
        cin >> X >> Y >> H;

        rc(X, -500, 500);
        rc(Y, -500, 500);
        rc(H, 1, 10000);
        
        X += OFFSET;
        Y += OFFSET;
        
        h[Y][X] = H;
    }
    
    for(int i=0;i<K;i++){
        int AX, AY, W, H, D;
        cin >> AX >> AY >> W >> H >> D;
        
        rc(AX, -500, 500);
        rc(AY, -500, 500);
        rc(W, 1, 500);
        rc(H, 1, 500);
        rc(D, 1, 10000);

        AX += OFFSET;
        AY += OFFSET;
        
        d[AY][AX] += D;
        d[AY][AX+W+1] -= D;
        d[AY+H+1][AX] -= D;
        d[AY+H+1][AX+W+1] += D;
    }
    
    for(int Y=0;Y<SIZE;Y++){
        for(int X=1;X<SIZE;X++){
            d[Y][X] += d[Y][X-1];
        }
    }
    
    for(int X=0;X<SIZE;X++){
        for(int Y=1;Y<SIZE;Y++){
            d[Y][X] += d[Y-1][X];
        }
    }
    
    int res = 0;
    for(int Y=0;Y<SIZE;Y++)for(int X=0;X<SIZE;X++){
        int rest = h[Y][X] - d[Y][X];
        if(rest > 0)res += rest;
    }

    cout << res << endl;
    return 0;
}
0