結果

問題 No.60 魔法少女
ユーザー tnakao0123tnakao0123
提出日時 2016-03-05 14:01:04
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 192 ms / 5,000 ms
コード長 1,476 bytes
コンパイル時間 726 ms
コンパイル使用メモリ 85,672 KB
実行使用メモリ 12,840 KB
最終ジャッジ日時 2023-10-24 19:53:41
合計ジャッジ時間 3,461 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
11,844 KB
testcase_01 AC 5 ms
11,844 KB
testcase_02 AC 5 ms
11,844 KB
testcase_03 AC 4 ms
12,688 KB
testcase_04 AC 105 ms
12,688 KB
testcase_05 AC 108 ms
12,820 KB
testcase_06 AC 186 ms
12,816 KB
testcase_07 AC 136 ms
12,720 KB
testcase_08 AC 86 ms
12,688 KB
testcase_09 AC 40 ms
12,688 KB
testcase_10 AC 169 ms
12,820 KB
testcase_11 AC 21 ms
12,688 KB
testcase_12 AC 74 ms
12,720 KB
testcase_13 AC 192 ms
12,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 60.cc: No.60 魔法少女 - yukicoder
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;
const int CX = 500;
const int CY = 500;
const int MAX_W = CX * 2 + 1;
const int MAX_H = CY * 2 + 1;

/* typedef */

/* global variables */

int xs[MAX_N], ys[MAX_N], hps[MAX_N];
int ds[MAX_H + 1][MAX_W + 1], dsums[MAX_H + 1][MAX_W + 1];

/* subroutines */

/* main */

int main() {
  int n, k;
  cin >> n >> k;

  for (int i = 0; i < n; i++) cin >> xs[i] >> ys[i] >> hps[i];

  for (int i = 0; i < k; i++) {
    int ax, ay, w, h, d;
    cin >> ax >> ay >> w >> h >> d;
    ax += CX, ay += CY;
    int bx = ax + w, by = ay + h;

    ds[ay][ax] += d;
    if (by < MAX_H) ds[by + 1][ax] -= d;
    if (bx < MAX_W) ds[ay][bx + 1] -= d;
    if (by < MAX_H && bx < MAX_W) ds[by + 1][bx + 1] += d;
  }

  for (int y = 0; y < MAX_H; y++)
    for (int x = 0; x < MAX_W; x++)
      dsums[y + 1][x + 1] =
	ds[y][x] + dsums[y + 1][x] + dsums[y][x + 1] - dsums[y][x];

  int rem = 0;
  for (int i = 0; i < n; i++) {
    int d = hps[i] - dsums[ys[i] + CY + 1][xs[i] + CX + 1];
    if (d > 0) rem += d;
  }
  printf("%d\n", rem);
  return 0;
}
0