結果

問題 No.60 魔法少女
ユーザー purple_jwlpurple_jwl
提出日時 2015-03-19 00:28:04
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 191 ms / 5,000 ms
コード長 1,085 bytes
コンパイル時間 1,288 ms
コンパイル使用メモリ 149,596 KB
実行使用メモリ 13,472 KB
最終ジャッジ日時 2023-09-11 08:33:47
合計ジャッジ時間 4,292 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
11,020 KB
testcase_01 AC 11 ms
10,960 KB
testcase_02 AC 11 ms
11,020 KB
testcase_03 AC 11 ms
11,280 KB
testcase_04 AC 105 ms
11,544 KB
testcase_05 AC 114 ms
13,300 KB
testcase_06 AC 183 ms
13,296 KB
testcase_07 AC 137 ms
12,552 KB
testcase_08 AC 92 ms
12,240 KB
testcase_09 AC 44 ms
11,488 KB
testcase_10 AC 173 ms
13,472 KB
testcase_11 AC 27 ms
11,484 KB
testcase_12 AC 81 ms
12,596 KB
testcase_13 AC 191 ms
13,336 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define REP(i, x, n) for(int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define F first
#define S second
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

int main() {
  // ios_base::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;

  vector<ll> X(N), Y(N), HP(N);
  rep(i, N) {
    cin >> X[i] >> Y[i] >> HP[i];
    X[i] += 500;
    Y[i] += 500;
  }

  vector<vector<ll>> dp(1010, vector<ll>(1010, 0));
  rep(i, K) {
    int AX, AY, W, H, D;
    cin >> AX >> AY >> W >> H >> D;
    AX += 500;
    AY += 500;
    int tx = min(1000, AX + W) + 1;
    int ty = min(1000, AY + H) + 1;
    dp[AY][AX] += D;
    dp[AY][tx] -= D;
    dp[ty][AX] -= D;
    dp[ty][tx] += D;
  }

  rep(i, 1005) rep(j, 1005) dp[i][j + 1] += dp[i][j];
  rep(j, 1005) rep(i, 1005) dp[i + 1][j] += dp[i][j];

  ll ans = 0;
  rep(i, N) ans += max(0LL, HP[i] - dp[Y[i]][X[i]]);

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