結果

問題 No.60 魔法少女
ユーザー なおなお
提出日時 2014-11-09 23:43:28
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 188 ms / 5,000 ms
コード長 1,014 bytes
コンパイル時間 1,168 ms
コンパイル使用メモリ 144,628 KB
実行使用メモリ 19,316 KB
最終ジャッジ日時 2023-08-30 02:51:09
合計ジャッジ時間 3,394 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
13,236 KB
testcase_01 AC 12 ms
13,208 KB
testcase_02 AC 12 ms
13,236 KB
testcase_03 AC 10 ms
17,768 KB
testcase_04 AC 101 ms
19,092 KB
testcase_05 AC 112 ms
19,316 KB
testcase_06 AC 181 ms
19,024 KB
testcase_07 AC 135 ms
19,068 KB
testcase_08 AC 89 ms
19,060 KB
testcase_09 AC 43 ms
19,040 KB
testcase_10 AC 171 ms
19,188 KB
testcase_11 AC 27 ms
19,288 KB
testcase_12 AC 80 ms
19,016 KB
testcase_13 AC 188 ms
19,012 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n)           for(int(i)=0;(i)<(n);++(i))
#define RREP(i, n)          for(int(i)=(n)-1;(i)>=0;--(i))

const int MOD = (int)(1e9+9);
const int B = 500;

ll HP[1001][1001];
ll DMG[1001][1001];

int main(){
    int N,K; cin >> N >> K;
    REP(i,N){
        int X,Y,H; cin >> X >> Y >> H;
        HP[B+Y][B+X] = H;
    }

    REP(i,K){
        int x,y,w,h,d;
        cin >> x >> y >> w >> h >> d;
        DMG[B+y][B+x] += d;
        if(B+y+h+1<=1000) DMG[B+y+h+1][B+x] -= d;
        if(B+x+w+1<=1000) DMG[B+y][B+x+w+1] -= d;
        if(B+y+h+1<=1000 && B+x+w+1 <= 1000) DMG[B+y+h+1][B+x+w+1] += d;
    }
    REP(y,1001) REP(x,1000){
        DMG[y][x+1] += DMG[y][x];
    }
    int sum = 0;
    REP(y,1001) REP(x,1001){
        if(y < 1000) DMG[y+1][x] += DMG[y][x];
        if(HP[y][x] > DMG[y][x]){
            sum += HP[y][x]-DMG[y][x];
        }
    }
    cout << sum << endl;
    return 0;
}
0