結果

問題 No.60 魔法少女
ユーザー te-shte-sh
提出日時 2016-09-05 10:52:20
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 166 ms / 5,000 ms
コード長 1,215 bytes
コンパイル時間 1,754 ms
コンパイル使用メモリ 116,860 KB
実行使用メモリ 19,244 KB
最終ジャッジ日時 2023-09-02 21:53:40
合計ジャッジ時間 4,318 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
6,688 KB
testcase_01 AC 11 ms
6,712 KB
testcase_02 AC 11 ms
6,700 KB
testcase_03 AC 11 ms
6,668 KB
testcase_04 AC 92 ms
10,704 KB
testcase_05 AC 105 ms
10,068 KB
testcase_06 AC 164 ms
19,244 KB
testcase_07 AC 120 ms
9,832 KB
testcase_08 AC 84 ms
9,104 KB
testcase_09 AC 43 ms
8,312 KB
testcase_10 AC 156 ms
18,868 KB
testcase_11 AC 29 ms
7,992 KB
testcase_12 AC 78 ms
8,812 KB
testcase_13 AC 166 ms
11,608 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.algorithm, std.array, std.container, std.range, std.bitmanip;
import std.numeric, std.math, std.bigint, std.random, core.bitop;
import std.string, std.conv, std.stdio, std.typecons;

alias Tuple!(int, "x", int, "y", int, "hp") monster;
alias Tuple!(int, "x", int, "y", int, "w", int, "h", int, "d") attack;

void main()
{
  auto rd = readln.split.map!(to!int);
  auto n = rd[0], k = rd[1];
  auto mi = iota(n)
    .map!(_ => readln.split.map!(to!int))
    .map!(rd => monster(rd[0], rd[1], rd[2])).array;
  auto ai = iota(k)
    .map!(_ => readln.split.map!(to!int))
    .map!(rd => attack(rd[0], rd[1], rd[2], rd[3], rd[4])).array;

  auto dij = new int[][](1002, 1002);
  foreach (a; ai) {
    auto l = a.x + 500, r = min(a.x + a.w + 1 + 500, 1001);
    auto t = a.y + 500, b = min(a.y + a.h + 1 + 500, 1001);
    dij[t][l] += a.d;
    dij[t][r] -= a.d;
    dij[b][l] -= a.d;
    dij[b][r] += a.d;
  }

  foreach (i; 1..1002)
    foreach (j; 0..1002)
      dij[j][i] += dij[j][i - 1];
  foreach (i; 1..1002)
    foreach (j; 0..1002)
      dij[i][j] += dij[i - 1][j];

  auto sum = 0;
  foreach (m; mi) {
    auto d = dij[m.y + 500][m.x + 500];
    if (d < m.hp) sum += m.hp - d;
  }

  writeln(sum);
}
0