結果

問題 No.60 魔法少女
ユーザー karaitarakokaraitarako
提出日時 2018-02-21 20:51:45
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 237 ms / 5,000 ms
コード長 1,139 bytes
コンパイル時間 2,302 ms
コンパイル使用メモリ 160,524 KB
実行使用メモリ 35,000 KB
最終ジャッジ日時 2023-10-19 14:16:59
合計ジャッジ時間 4,207 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
24,760 KB
testcase_01 AC 28 ms
24,760 KB
testcase_02 AC 27 ms
24,760 KB
testcase_03 AC 31 ms
32,952 KB
testcase_04 AC 143 ms
35,000 KB
testcase_05 AC 149 ms
35,000 KB
testcase_06 AC 230 ms
35,000 KB
testcase_07 AC 176 ms
35,000 KB
testcase_08 AC 123 ms
35,000 KB
testcase_09 AC 68 ms
35,000 KB
testcase_10 AC 217 ms
35,000 KB
testcase_11 AC 50 ms
35,000 KB
testcase_12 AC 112 ms
35,000 KB
testcase_13 AC 237 ms
35,000 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

const int lengh_max = 1502;

long long int enemy[lengh_max][lengh_max];
long long int imos[lengh_max][lengh_max];

int main() {

    int n,k;

    cin >> n >> k;

    for(int i=0; i<n; i++){
        int x,y,hp;
        cin >> x >> y >> hp;
        enemy[x+500][y+500] = hp;
    }

    for(int i=0; i<k; i++){
        int ax,ay,w,h,d;
        cin >> ax >> ay >> w >> h >> d;
        imos[ax+500][ay+500] += d;
        imos[ax+500+w+1][ay+500] += -d;
        imos[ax+500][ay+500+h+1] += -d;
        imos[ax+500+w+1][ay+500+h+1] += d;
    }

    for(int i=0; i<lengh_max; i++){
        for(int j=1; j<lengh_max; j++){
            imos[i][j] += imos[i][j-1];
        }
    }

    for(int j=0; j<lengh_max; j++){
        for(int i=1; i<lengh_max; i++){
            imos[i][j] += imos[i-1][j];
        }
    }

    long long int ans = 0;

    for(int i=0; i<lengh_max; i++){
        for(int j=0; j<lengh_max; j++){
            if(enemy[i][j] != 0 && enemy[i][j] > imos[i][j]){
                ans += enemy[i][j] - imos[i][j];
            }
        }
    }

    cout << ans << endl;

    return 0;
}
0