結果

問題 No.60 魔法少女
ユーザー sssr1031sssr1031
提出日時 2022-07-03 19:00:19
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 156 ms / 5,000 ms
コード長 844 bytes
コンパイル時間 1,833 ms
コンパイル使用メモリ 203,040 KB
実行使用メモリ 8,272 KB
最終ジャッジ日時 2023-08-19 19:33:47
合計ジャッジ時間 4,509 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
7,364 KB
testcase_01 AC 4 ms
7,352 KB
testcase_02 AC 4 ms
7,408 KB
testcase_03 AC 4 ms
7,352 KB
testcase_04 AC 84 ms
7,616 KB
testcase_05 AC 91 ms
8,072 KB
testcase_06 AC 148 ms
8,068 KB
testcase_07 AC 111 ms
7,724 KB
testcase_08 AC 70 ms
7,800 KB
testcase_09 AC 33 ms
7,612 KB
testcase_10 AC 136 ms
7,952 KB
testcase_11 AC 18 ms
7,668 KB
testcase_12 AC 65 ms
7,688 KB
testcase_13 AC 156 ms
8,272 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int main(void) {
  int N, K;
  cin >> N >> K;

  vector<int> x(N), y(N), hp(N);
  for (int i = 0; i < N; ++i) {
    cin >> x[i] >> y[i] >> hp[i];

    x[i] += 501;
    y[i] += 501;
  }

  vector<vector<int>> sum(1005, vector<int>(1005, 0));
  for (int i = 0; i < K; ++i) {
    int ax, ay, w, h, d;
    cin >> ax >> ay >> w >> h >> d;

    ax += 501;
    ay += 501;

    int gx = min(ax + w + 1, 1004), gy = min(ay + h + 1, 1004);

    sum[ax][ay] += d;
    sum[gx][ay] -= d;
    sum[ax][gy] -= d;
    sum[gx][gy] += d;
  }

  for (int i = 1; i < 1005; ++i) {
    for (int j = 1; j < 1005; ++j) {
      sum[i][j] += sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1];
    }
  }

  int ans = 0;
  for (int i = 0; i < N; ++i)
    ans += max(0, hp[i] - sum[x[i]][y[i]]);

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