No.60 Magical Girl
タグ : / 解いたユーザー数 205
作問者 :
Problem Statement
The magical girl Madoka was fighting the witch Walpurgisnacht.
Since Walpurgisnacht commands multiple familiars, she cannot be defeated unless all the enemies are damaged within a short time.
Madoka therefore decided to use an attack spell that targets an area in order to defeat the enemies efficiently.
You are given the coordinates and HP of Walpurgisnacht and her familiars, and the areas Madoka attacked along with the damage dealt to enemies.
Find the total remaining HP of the enemies that have not been defeated.
Input
\(N\) \(K\)
\(X_{1}\) \(Y_{1}\) \({HP}_{1}\)
\(X_{2}\) \(Y_{2}\) \({HP}_{2}\)
\(\ldots\)
\(X_{N}\) \(Y_{N}\) \({HP}_{N}\)
\(AX_{1}\) \(AY_{1}\) \(W_{1}\) \(H_{1}\) \(D_{1}\)
\(AX_{2}\) \(AY_{2}\) \(W_{2}\) \(H_{2}\) \(D_{2}\)
\(\ldots\)
\(AX_{K}\) \(AY_{K}\) \(W_{K}\) \(H_{K}\) \(D_{K}\)
All input values are integers.
- \(1 \leq N \leq 100000\) is the number of enemies.
- \(1 \leq K \leq 100000\) is the number of Madoka's attacks.
- \(-500 \leq X_{k}, Y_{k} \leq 500\) are the coordinates of the \(k\)-th enemy.
- \(1 \leq {HP}_{k} \leq 10000\) is the HP of the \(k\)-th enemy.
- \(-500 \leq AX_{t}, AY_{t} \leq 500\)
- \(1 \leq W_{t}, H_{t} \leq 500\)
- \(1 \leq D_{t} \leq 10000\)
- The \(t\)-th attack deals \(D\) damage to every enemy satisfying \(AX_{t} \leq X \leq AX_{t} + W_{t}\) and \(AY_{t} \leq Y \leq AY_{t} + H_{t}\).
- No two enemies exist at the same coordinates.
- The same attack may be performed multiple times.
Output
An enemy is defeated when it has received damage greater than or equal to its HP. Compute and output the total HP of the enemies that have not been defeated.
Sample
Sample 1
Input
7 2 0 0 1 1 0 1 1 1 2 1 2 1 2 0 1 2 1 1 2 2 1 -1 -1 2 2 1 1 0 1 2 1
Output
0
All the enemies have been defeated, so the total remaining HP is 0.
Sample 2
Input
4 1 1 0 1 1 2 1 2 0 2 2 1 1 -1 -1 3 3 2
Output
0
Sample 3
Input
4 1 1 0 2 1 2 1 2 0 1 2 1 1 -1 0 3 3 1
Output
1
Sample 4
Input
10 10 -444 -456 6808 465 31 3659 -16 103 7545 199 342 7710 374 -206 4493 -15 -286 2504 -287 155 8841 -345 -444 3170 -7 304 9561 -143 -456 279 -349 154 13 268 3811 -40 256 150 80 8822 486 270 394 337 5486 310 -342 92 195 6358 111 -243 209 445 5669 -224 -120 197 31 904 436 -206 50 25 7802 -394 -493 409 229 4934 -388 367 136 14 3866 -79 -157 37 426 1670
Output
35302
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。