結果

問題 No.60 魔法少女
ユーザー ninoinui
提出日時 2020-09-06 16:13:18
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
RE  
実行時間 -
コード長 966 bytes
コンパイル時間 3,031 ms
コンパイル使用メモリ 201,956 KB
最終ジャッジ日時 2025-01-14 07:51:18
ジャッジサーバーID
(参考情報)
judge4 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 8 RE * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  vector<tuple<int, int, int>> V(N);
  for (int i = 0; i < N; i++) {
    int x, y, hp;
    cin >> x >> y >> hp;
    V.at(i) = {x + 500, y + 500, hp};
  }
  N = 1501;
  vector DP(N, vector(N, 0));
  for (int i = 0; i < K; i++) {
    int ax, ay, w, h, d;
    cin >> ax >> ay >> w >> h >> d;
    ax += 500, ay += 500;
    DP.at(ax).at(ay) += d;
    DP.at(ax + w + 1).at(ay) -= d;
    DP.at(ax).at(ay + h + 1) -= d;
    DP.at(ax + w + 1).at(ay + h + 1) += d;
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j + 1 < N; j++) {
      DP.at(i).at(j + 1) += DP.at(i).at(j);
    }
  }
  for (int i = 0; i + 1 < N; i++) {
    for (int j = 0; j < N; j++) {
      DP.at(i + 1).at(j) += DP.at(i).at(j);
    }
  }
  long ans = 0;
  for (auto [x, y, hp] : V) {
    ans += max(0, hp - DP.at(x).at(y));
  }
  cout << ans << "\n";
}
0