結果

問題 No.60 魔法少女
ユーザー Grun1396Grun1396
提出日時 2018-04-11 13:33:34
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 195 ms / 5,000 ms
コード長 1,283 bytes
コンパイル時間 639 ms
コンパイル使用メモリ 79,316 KB
実行使用メモリ 20,036 KB
最終ジャッジ日時 2023-09-09 04:04:12
合計ジャッジ時間 3,679 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
19,112 KB
testcase_01 AC 30 ms
19,008 KB
testcase_02 AC 31 ms
19,220 KB
testcase_03 AC 24 ms
18,964 KB
testcase_04 AC 113 ms
19,112 KB
testcase_05 AC 120 ms
20,036 KB
testcase_06 AC 190 ms
20,020 KB
testcase_07 AC 147 ms
19,756 KB
testcase_08 AC 98 ms
19,500 KB
testcase_09 AC 53 ms
19,144 KB
testcase_10 AC 182 ms
19,964 KB
testcase_11 AC 37 ms
19,164 KB
testcase_12 AC 89 ms
19,696 KB
testcase_13 AC 195 ms
19,928 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cctype>
#include <functional>
#include <map>
#include <cstdio>
using namespace std;
typedef long long ll;

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
const int INF = 1e9;
struct enemy{
    int x, y, hp;
};
const int LENGTH = 2e3;
int board[LENGTH][LENGTH];

int main(){
    int n,k;
    int x,y,hp;
    int ax,ay,w,h,d;
    cin >> n >> k;
    vector<enemy> enemy_data;
    rep(i,n){
        cin >> x >> y >> hp;
        x+=500;
        y+=500;
        enemy_data.push_back({x,y,hp});
    }
    rep(i,k){
        cin >> ax >> ay >> w >> h >> d;
        ax += 500; ay += 500;
        //
        board[ax][ay] += d;
        board[ax+w+1][ay] -= d;
        board[ax][ay+h+1] -= d;
        board[ax+w+1][ay+h+1] += d;
    }
    //横方向に累積
    rep(j,LENGTH){//y
        rep(i,LENGTH-1){//x
            board[i+1][j] += board[i][j];
        }
    }
    //縦方向に累積
    rep(i,LENGTH){//x
        rep(j,LENGTH-1){//y
            board[i][j+1] += board[i][j];
        }
    }

    
    int ans = 0;
    rep(i,n){
        enemy e = enemy_data[i];
        ans += max(e.hp - board[e.x][e.y],0);
    }
    

    cout << ans << endl;
    return 0;
}
0