結果

問題 No.60 魔法少女
ユーザー krotonkroton
提出日時 2014-11-09 21:30:54
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 211 ms / 5,000 ms
コード長 1,611 bytes
コンパイル時間 577 ms
コンパイル使用メモリ 53,028 KB
実行使用メモリ 21,456 KB
最終ジャッジ日時 2023-08-30 02:48:32
合計ジャッジ時間 3,400 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
15,372 KB
testcase_01 AC 26 ms
15,316 KB
testcase_02 AC 26 ms
15,312 KB
testcase_03 AC 25 ms
19,768 KB
testcase_04 AC 123 ms
21,240 KB
testcase_05 AC 134 ms
21,456 KB
testcase_06 AC 205 ms
21,212 KB
testcase_07 AC 156 ms
21,252 KB
testcase_08 AC 109 ms
21,228 KB
testcase_09 AC 61 ms
21,340 KB
testcase_10 AC 193 ms
21,396 KB
testcase_11 AC 45 ms
21,264 KB
testcase_12 AC 100 ms
21,260 KB
testcase_13 AC 211 ms
21,444 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];
bool used[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;
        
        if(used[X][Y]){
            cerr << "error" << endl;
            exit(1);
        } else {
            used[X][Y] = true;
        }

        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