結果

問題 No.60 魔法少女
ユーザー nanophoto12nanophoto12
提出日時 2014-11-10 00:51:51
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,875 bytes
コンパイル時間 4,480 ms
コンパイル使用メモリ 104,268 KB
実行使用メモリ 43,332 KB
最終ジャッジ日時 2023-08-30 02:58:32
合計ジャッジ時間 7,301 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
23,344 KB
testcase_01 AC 75 ms
21,448 KB
testcase_02 AC 77 ms
23,308 KB
testcase_03 AC 85 ms
27,488 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Linq;

class Program
{
    public static void Main(string[] args)
    {
        var first = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var enemies = new long[1001,1001];
        int n = first[0];
        int k = first[1];
        const int offset = 500;
        for (int i = 0; i < n; i++)
        {
            var enemy = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            enemies[enemy[0] + offset, enemy[1] + offset] = enemy[2];
        }
        var attacks = new long[1001, 1001];
        for (int j = 0; j < k; j++)
        {
            var attack = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var left = attack[0] + offset;
            var top = attack[1] + offset;
            var right = left + attack[2] + 1;
            right = Math.Min(1000, right);
            var bottom = top + attack[3] + 1;
            bottom = Math.Min(1000, bottom);
            for (int y = top; y < bottom; y++)
            {
                attacks[left, y] += attack[4];
                if (right == 1000)
                {
                    if (y < 1000)
                    {
                        attacks[0, y + 1] -= attack[4];                        
                    }
                }
                else
                {
                    attacks[right, y] -= attack[4];
                }
            }
        }
        long current = 0;
        long sum = 0;
        for (int y = 0; y < 1001; y++)
        {
            for (int x = 0; x < 1001; x++)
            {
                current += attacks[x, y];
                if (current < enemies[x, y])
                {
                    sum += enemies[x, y] - current;
                }
            }
        }
        Console.WriteLine(sum);
    }
}
0