結果

問題 No.60 魔法少女
ユーザー syoken_desukasyoken_desuka
提出日時 2015-03-05 01:32:32
言語 C#(csc)
(csc 3.9.0)
結果
RE  
実行時間 -
コード長 5,855 bytes
コンパイル時間 2,235 ms
コンパイル使用メモリ 108,004 KB
実行使用メモリ 65,944 KB
最終ジャッジ日時 2023-09-06 13:25:27
合計ジャッジ時間 6,684 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 135 ms
42,064 KB
testcase_01 AC 137 ms
42,004 KB
testcase_02 AC 138 ms
42,056 KB
testcase_03 AC 140 ms
42,092 KB
testcase_04 AC 297 ms
62,832 KB
testcase_05 AC 313 ms
65,732 KB
testcase_06 RE -
testcase_07 AC 344 ms
65,832 KB
testcase_08 AC 279 ms
65,220 KB
testcase_09 AC 210 ms
60,852 KB
testcase_10 AC 400 ms
63,764 KB
testcase_11 AC 168 ms
45,808 KB
testcase_12 AC 270 ms
65,944 KB
testcase_13 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

#region ZIPPER
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
using System.Numerics;
using sc = Scanner;
class Program
{
    static void Main(string[] args)
    {
        Solver solver = new Solver();
        solver.Solve();
#if DEBUG
        System.Console.WriteLine("続行するには何かキーを押してください...");
        System.Console.ReadKey();
#endif

    }
}
/// <summary>
/// Java風のスキャナー,自作(某最速の人を参考) 自分の実装のせいか,バグってるっぽい バグが出たらO(n^3) n=100000 でTLE
/// </summary>
public static class Scanner
{
    public static string NextString()
    {
        string tmp = "";
        while (true)
        {
            int readData;
            string data;
            readData = Console.Read();
            if (readData == -1) //EOF
            {
                break;
            }
            data = char.ConvertFromUtf32(readData);
            if (data == " " || data == "\n")
            {
                break;
            }
            tmp += data;
        }
        return tmp;
    }
    public static int NextInt()
    {
        string tmp = "";
        while (true)
        {
            int readData;
            string data;
            readData = Console.Read();
            if (readData == -1) //EOF
            {
                break;
            }
            data = char.ConvertFromUtf32(readData);
            if (data == " " || data == "\n")
            {
                break;
            }
            tmp += data;
        }
        return int.Parse(tmp);
    }
    public static long NextLong()
    {
        string tmp = "";
        while (true)
        {
            int readData;
            string data;
            readData = Console.Read();
            if (readData == -1) //EOF
            {
                break;
            }
            data = char.ConvertFromUtf32(readData);
            if (data == " " || data == "\n")
            {
                break;
            }
            tmp += data;
        }
        return long.Parse(tmp);
    }
    public static double NextDouble()
    {
        string tmp = "";
        while (true)
        {
            int readData;
            string data;
            readData = Console.Read();
            if (readData == -1) //EOF
            {
                break;
            }
            data = char.ConvertFromUtf32(readData);
            if (data == " " || data == "\n")
            {
                break;
            }
            tmp += data;
        }
        return double.Parse(tmp);
    }

    public static string[] NextStrArray()
    {
        return Console.ReadLine().Split(' ');
    }
    public static int[] NextIntArray()
    {

        string[] s = NextStrArray();
        int[] a = new int[s.Length];
        for (int i = 0; i < a.Length; i++)
        {
            a[i] = int.Parse(s[i]);
        }
        return a;
    }
    public static long[] NextLongArray()
    {
        string[] s = NextStrArray();
        long[] a = new long[s.Length];
        for (int i = 0; i < a.Length; i++)
        {
            a[i] = long.Parse(s[i]);
        }
        return a;
    }
    public static double[] NextDoubleArray()
    {
        string[] s = NextStrArray();
        double[] a = new double[s.Length];
        for (int i = 0; i < a.Length; i++)
        {
            a[i] = double.Parse(s[i]);
        }
        return a;
    }
}
#endregion ZIPPER


public class Solver
{
#region IGNORE_ME
    public Solver()
    {
        //こんすとらくたん きにしなくてよろしい
    }
#endregion IGNORE_ME

#region FIELD

#endregion FIELD

    public void Solve()
    {
        try
        {
            int n = sc.NextInt();
            int k = sc.NextInt();
            long[][] enemys = new long[n][];
            long[,] map = new long[1501, 1501]; // 500 ga center [1001] bunki wo rakuni
            long[,] imositaMap = new long[1501, 1501];
            for (int i = 0; i < n; i++)
            {
                enemys[i] = sc.NextLongArray();// 0x 1y 2hp
                enemys[i][0] += 500;//centering
                enemys[i][1] += 500;
            }
            for (int i = 0; i < k; i++)
            {
                int[] data = sc.NextIntArray();
                data[0] += 500;
                data[1] += 500;
                map[data[0], data[1]] += data[4];
                map[data[0] + data[2] + 1, data[1]] -= data[4];
                map[data[0], data[1] + data[3] + 1] -= data[4];
                map[data[0] + data[2] + 1, data[1] + data[3] + 1] += data[4];
            }

            for (int i = 0; i < 1501; i++)
            {
                long tmp = 0;
                for (int j = 0; j < 1501; j++)
                {
                    tmp += map[i, j];
                    imositaMap[i, j] += tmp;
                }
            }
            for (int i = 0; i < 1501; i++)
            {
                long tmp = 0;
                for (int j = 0; j < 1501; j++)
                {
                    tmp += imositaMap[j, i];
                    imositaMap[j, i] = tmp;
                }
            }

            for (int i = 0; i < enemys.Length; i++)
            {
                long x = enemys[i][0];
                long y = enemys[i][1];

                enemys[i][2] = Math.Max(0, enemys[i][2] - imositaMap[x, y]);
            }

            long answer = 0;
            for (int i = 0; i < enemys.Length; i++)
            {
                answer += enemys[i][2];
            }
            Console.WriteLine(answer);
        }
        catch (System.IO.IOException e)
        {
            System.Threading.Thread.Sleep(5000);//re ga tle ni naruhazu
        }
#if DEBUG
        Console.WriteLine("");//local check
#endif 
    }
}
0