結果

問題 No.60 魔法少女
ユーザー 14番14番
提出日時 2016-04-07 07:56:42
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 715 ms / 5,000 ms
コード長 2,527 bytes
コンパイル時間 930 ms
コンパイル使用メモリ 116,652 KB
実行使用メモリ 37,248 KB
最終ジャッジ日時 2024-04-14 22:23:23
合計ジャッジ時間 6,550 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
27,356 KB
testcase_01 AC 76 ms
25,244 KB
testcase_02 AC 75 ms
27,552 KB
testcase_03 AC 79 ms
29,092 KB
testcase_04 AC 448 ms
35,208 KB
testcase_05 AC 358 ms
37,000 KB
testcase_06 AC 659 ms
37,240 KB
testcase_07 AC 504 ms
34,952 KB
testcase_08 AC 323 ms
35,060 KB
testcase_09 AC 190 ms
37,248 KB
testcase_10 AC 602 ms
37,248 KB
testcase_11 AC 113 ms
35,212 KB
testcase_12 AC 278 ms
35,204 KB
testcase_13 AC 715 ms
35,200 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.Collections.Generic;
using System.Text;

public class Program
{
    public void Proc(){
        Reader.IsDebug = false;
        int[] inpt = Reader.GetInt(' ', true);
        
        int tekiCount = inpt[0];
        int kougekiCount = inpt[1];
        
        int[,] teki = new int[1002, 1002];
        for(int i=0; i<tekiCount; i++) {
            inpt = Reader.GetInt(' ', true);
            teki[inpt[1] + 500, inpt[0] + 500] = inpt[2];
        }
        
        int[,] map = new int[1002,1002];
        
        for(int i=0; i<kougekiCount; i++) {
            inpt = Reader.GetInt(' ', true);
            int x = inpt[0] + 500;
            int y = inpt[1] + 500;
            int w = inpt[2];
            int h = inpt[3];
            int d = inpt[4];
            int rowMax = Math.Min(y+h, map.GetLength(0) - 1);
            int colMax = Math.Min(x+w + 1, map.GetLength(1) - 1);
            for(int j=y; j<=rowMax; j++) {
                map[j, x]+=d;
                map[j, colMax] -= d;
            }
        }
        
        int currentNum = 0;
        long ans = 0;
        for(int i=0; i<map.GetLength(0); i++) {
            for(int j=0; j<map.GetLength(1); j++) {
                currentNum += map[i,j];
                if(teki[i,j] > currentNum) {
                    ans += (teki[i,j] - currentNum);
                }
            }
        }
        Console.WriteLine(ans.ToString("#########################0"));


    }
    
    
    
    public static void Main(string[] args)
    {
        Program prg = new Program();
        prg.Proc();
    }
}

class Reader
{
    public static bool IsDebug = true;
    
    private static System.IO.StringReader sr;
    
    public static string ReadLine() {
        if(IsDebug) {
            if(sr == null) {
                sr = new System.IO.StringReader(initStr.Trim());
            }
            return sr.ReadLine();
        } else {
            return Console.ReadLine();
        }
    }
    
    public static int[] GetInt(char delimiter = ' ', bool mustTrim = false) {
        string src = ReadLine();
        if(mustTrim) {
            src = src.Trim();
        }
        string[] inpt = src.Split(delimiter);
        int[] ret = new int[inpt.Length];
        for(int i=0; i<inpt.Length; i++) {
            string item = inpt[i];
            if(mustTrim) {
                item = item.Trim();
            }
            ret[i] = int.Parse(item);
        }
        return ret;
    }
    
    private static string initStr = @"



";
}


0