結果

問題 No.60 魔法少女
ユーザー face4face4
提出日時 2018-11-03 08:41:29
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 87 ms / 5,000 ms
コード長 826 bytes
コンパイル時間 974 ms
コンパイル使用メモリ 65,292 KB
実行使用メモリ 13,652 KB
最終ジャッジ日時 2023-08-13 02:02:20
合計ジャッジ時間 2,955 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
12,456 KB
testcase_01 AC 13 ms
12,272 KB
testcase_02 AC 12 ms
12,296 KB
testcase_03 AC 9 ms
12,268 KB
testcase_04 AC 51 ms
12,548 KB
testcase_05 AC 51 ms
13,652 KB
testcase_06 AC 84 ms
13,420 KB
testcase_07 AC 63 ms
13,068 KB
testcase_08 AC 41 ms
12,972 KB
testcase_09 AC 23 ms
12,612 KB
testcase_10 AC 80 ms
13,644 KB
testcase_11 AC 15 ms
12,540 KB
testcase_12 AC 37 ms
13,076 KB
testcase_13 AC 87 ms
13,492 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
using namespace std;
typedef long long ll;

int sum[1505][1505] = {};

int main(){
    int n, k;
    scanf("%d %d", &n, &k);

    int x[n], y[n], hp[n];
    for(int i = 0; i < n; i++)  scanf("%d %d %d", x+i, y+i, hp+i);

    int ax, ay, w, h, d;
    for(int i = 0; i < k; i++){
        scanf("%d %d %d %d %d", &ax, &ay, &w, &h, &d);
        ax += 501;
        ay += 501;
        sum[ax][ay] += d;
        sum[ax+w+1][ay] -= d;
        sum[ax][ay+h+1] -= d;
        sum[ax+w+1][ay+h+1] += d;
    }

    for(int i = 1; i < 1505; i++){
        for(int j = 1; j < 1505; j++){
            sum[i][j] += sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1];
        }
    }

    ll ans = 0;
    for(int i = 0; i < n; i++){
        ans += max(0, hp[i]-sum[x[i]+501][y[i]+501]);
    }

    cout << ans << endl;

    return 0;
}
0