結果

問題 No.60 魔法少女
ユーザー TamuoTamuoTamuoTamuoTamuoTamuo
提出日時 2019-06-19 09:25:35
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 197 ms / 5,000 ms
コード長 1,883 bytes
コンパイル時間 708 ms
コンパイル使用メモリ 78,856 KB
実行使用メモリ 21,416 KB
最終ジャッジ日時 2023-08-20 07:13:26
合計ジャッジ時間 3,535 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
21,176 KB
testcase_01 AC 17 ms
21,152 KB
testcase_02 AC 16 ms
21,156 KB
testcase_03 AC 17 ms
21,136 KB
testcase_04 AC 112 ms
21,216 KB
testcase_05 AC 123 ms
21,132 KB
testcase_06 AC 191 ms
21,140 KB
testcase_07 AC 144 ms
21,208 KB
testcase_08 AC 98 ms
21,208 KB
testcase_09 AC 50 ms
21,148 KB
testcase_10 AC 182 ms
21,416 KB
testcase_11 AC 33 ms
21,172 KB
testcase_12 AC 88 ms
21,140 KB
testcase_13 AC 197 ms
21,140 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<set>
#include<vector>
#include<map>

using namespace std;
#define REP(i, n, N) for(int i=(n); i<(N); i++)
#define RREP(i, n, N) for(int i=(N-1); i>=n; i--)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define v2(T) vector<vector<T>>
typedef long long ll;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

#define CONVERT 500

int main(){
    int n,k,ans=0;
    int e_field[1510][1510];
    int m_field[1510][1510];
    REP(i,0,1510){
        REP(j,0,1510){
            e_field[i][j]=0;
            m_field[i][j]=0;
        }
    }
	cin >> n >> k;
    //敵の位置と体力
    REP(i,0,n){
        int x,y,hp;
        cin >> x >> y >> hp;
        x += CONVERT;
        y += CONVERT;
        e_field[y][x] = hp;
    }

    //いもす法step1 累積和のための前処理 
    REP(i,0,k){
        int ax,ay,w,h,d;
        cin >> ax >> ay >> w >> h >> d;
        ax += CONVERT;
        ay += CONVERT;
        m_field[ay][ax] += d;
        m_field[ay+h+1][ax] -= d;
        m_field[ay][ax+w+1] -= d;
        m_field[ay+h+1][ax+w+1] += d;
    }
    //いもす法step2 累積和をとってダメージフィールドを作成
    //x軸の累積和
    REP(i,0,1510){
        REP(j,0,1510){
            if(j==0)continue;
            m_field[i][j]+=m_field[i][j-1];
        }
    }
    //y軸の累積和
    REP(i,0,1510){
        REP(j,0,1510){
            if(i==0)continue;
            m_field[i][j]+=m_field[i-1][j];
        }
    }
    
    //体力がどれだけ残るか計算
    int sub;
    REP(i,0,1510){
        REP(j,0,1510){
            sub=e_field[i][j]-m_field[i][j];
            ans+=max(0,sub);
        }
    }

    p(ans);
}
0