結果

問題 No.60 魔法少女
ユーザー yukirinyukirin
提出日時 2016-03-29 16:04:51
言語 Go
(1.22.1)
結果
AC  
実行時間 279 ms / 5,000 ms
コード長 1,270 bytes
コンパイル時間 10,749 ms
コンパイル使用メモリ 220,868 KB
実行使用メモリ 20,420 KB
最終ジャッジ日時 2024-04-19 07:09:08
合計ジャッジ時間 13,787 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
8,128 KB
testcase_01 AC 6 ms
8,132 KB
testcase_02 AC 6 ms
8,132 KB
testcase_03 AC 8 ms
20,420 KB
testcase_04 AC 201 ms
20,420 KB
testcase_05 AC 116 ms
20,416 KB
testcase_06 AC 274 ms
20,416 KB
testcase_07 AC 197 ms
20,420 KB
testcase_08 AC 117 ms
20,416 KB
testcase_09 AC 60 ms
20,420 KB
testcase_10 AC 244 ms
20,416 KB
testcase_11 AC 15 ms
20,420 KB
testcase_12 AC 82 ms
20,416 KB
testcase_13 AC 279 ms
20,416 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	n, k := nextInt(), nextInt()
	m := make([][]int, 1001)
	eria := make([][]int, 1001)
	for i := range m {
		m[i] = make([]int, 1001)
		eria[i] = make([]int, 1002)
	}

	for i := 0; i < n; i++ {
		x, y, hp := nextInt(), nextInt(), nextInt()
		m[y+500][x+500] = hp
	}

	for i := 0; i < k; i++ {
		x, y, w, h, d := nextInt(), nextInt(), nextInt(), nextInt(), nextInt()
		x += 500
		y += 500
		for j := 0; j <= h; j++ {
			if y+j > 1000 {
				continue
			}

			eria[y+j][x] += d

			xP := x + w + 1
			if xP > 1001 {
				xP = 1001
			}
			eria[y+j][xP] -= d
		}
	}

	dTotal := 0
	for i, v := range eria {
		sum := 0
		for j, v2 := range v[:1001] {
			sum += v2
			if m[i][j] <= sum {
				continue
			}
			dTotal += m[i][j] - sum
		}
	}
	fmt.Println(dTotal)
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextLine())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextLine(), 10, 64)
	return i
}

func nextUint64() uint64 {
	i, _ := strconv.ParseUint(nextLine(), 10, 64)
	return i
}

func nextFloat() float64 {
	f, _ := strconv.ParseFloat(nextLine(), 64)
	return f
}
0