結果

問題 No.60 魔法少女
ユーザー koprickykopricky
提出日時 2017-08-18 09:50:36
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 67 ms / 5,000 ms
コード長 1,658 bytes
コンパイル時間 1,440 ms
コンパイル使用メモリ 162,184 KB
実行使用メモリ 8,252 KB
最終ジャッジ日時 2024-04-22 15:42:05
合計ジャッジ時間 3,295 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
7,296 KB
testcase_01 AC 5 ms
7,296 KB
testcase_02 AC 6 ms
7,260 KB
testcase_03 AC 6 ms
7,276 KB
testcase_04 AC 36 ms
7,464 KB
testcase_05 AC 40 ms
8,120 KB
testcase_06 AC 64 ms
8,192 KB
testcase_07 AC 48 ms
7,808 KB
testcase_08 AC 31 ms
7,660 KB
testcase_09 AC 15 ms
7,424 KB
testcase_10 AC 60 ms
8,252 KB
testcase_11 AC 11 ms
7,552 KB
testcase_12 AC 29 ms
7,936 KB
testcase_13 AC 67 ms
8,192 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(a, b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 1005;

int dp[MAX_N][MAX_N];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,K;
    cin >> n >> K;
    vector<P> pos(n);
    vector<int> hp(n);
    rep(i,n){
        int x,y;
        cin >> x >> y >> hp[i];
        pos[i] = P(x+500,y+500);
    }
    rep(i,K){
        int a,b,w,h,e;
        cin >> a >> b >> w >> h >> e;
        a += 500,b += 500;
        dp[a][b] -= e;
        dp[min(a+w,1000)+1][b] += e;
        dp[a][min(b+h,1000)+1] += e;
        dp[min(a+w,1000)+1][min(b+h,1000)+1] -= e;
    }
    rep(i,1002){
        rep(j,1002){
            dp[i][j+1] += dp[i][j];
        }
    }
    rep(i,1002){
        rep(j,1002){
            dp[i+1][j] += dp[i][j];
        }
    }
    ll ans = 0;
    rep(i,n){
        if(hp[i] + dp[pos[i].fi][pos[i].se] > 0){
            ans += hp[i] + dp[pos[i].fi][pos[i].se];
        }
    }
    cout << ans << endl;
    return 0;
}
0