結果
| 問題 |
No.60 魔法少女
|
| コンテスト | |
| ユーザー |
nanophoto12
|
| 提出日時 | 2014-11-10 01:06:12 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 531 ms / 5,000 ms |
| コード長 | 1,877 bytes |
| コンパイル時間 | 1,025 ms |
| コンパイル使用メモリ | 110,476 KB |
| 実行使用メモリ | 46,356 KB |
| 最終ジャッジ日時 | 2024-12-31 09:16:38 |
| 合計ジャッジ時間 | 5,513 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 10 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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(1001, 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);
}
}
nanophoto12