結果
| 問題 |
No.60 魔法少女
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2016-03-05 14:01:04 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 193 ms / 5,000 ms |
| コード長 | 1,476 bytes |
| コンパイル時間 | 756 ms |
| コンパイル使用メモリ | 86,204 KB |
| 実行使用メモリ | 12,676 KB |
| 最終ジャッジ日時 | 2024-09-24 14:19:40 |
| 合計ジャッジ時間 | 3,327 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 10 |
ソースコード
/* -*- 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;
}
tnakao0123