結果
| 問題 | No.60 魔法少女 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2016-09-05 10:52:20 | 
| 言語 | D (dmd 2.109.1) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 171 ms / 5,000 ms | 
| コード長 | 1,215 bytes | 
| コンパイル時間 | 862 ms | 
| コンパイル使用メモリ | 129,664 KB | 
| 実行使用メモリ | 17,536 KB | 
| 最終ジャッジ日時 | 2024-06-12 04:08:40 | 
| 合計ジャッジ時間 | 3,408 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 10 | 
ソースコード
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);
}
            
            
            
        