結果

問題 No.60 魔法少女
ユーザー 👑 はまやんはまやんはまやんはまやん
提出日時 2015-06-24 17:24:52
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 1,352 bytes
コンパイル時間 2,315 ms
コンパイル使用メモリ 74,368 KB
実行使用メモリ 71,688 KB
最終ジャッジ日時 2023-09-22 00:32:34
合計ジャッジ時間 9,853 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 135 ms
60,308 KB
testcase_01 AC 132 ms
60,452 KB
testcase_02 AC 132 ms
60,604 KB
testcase_03 AC 156 ms
60,188 KB
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Scanner;
import java.util.TreeSet;

public class Main {
	static int N, K;
	static int[] X, Y, HP;
	static int[] AX, AY, W, H, D;
	
	public static int solve(){
		int[][] damage = new int[1001][1001];
		for (int y = 0; y < 1001; y++) {
			for (int x = 0; x < 1001; x++) {
				damage[y][x] = 0;
			}
		}
		
		for (int i = 0; i < K; i++) {
			for (int y = AY[i]; y <= AY[i]+H[i]; y++) {
				if(1000 < y) continue;
				for (int x = AX[i]; x <= AX[i]+W[i]; x++) {
					if(1000 < x) continue;
					damage[y][x] += D[i];
				}
			}
		}
		
		int ret = 0;
		for (int i = 0; i < N; i++) {
			int delta = HP[i] - damage[Y[i]][X[i]];
			if(delta > 0) ret += delta;
		}
		
		System.out.println(ret);
		
		return 0;
	}
	
	public static void main(String[] args){
		Scanner S = new Scanner(System.in);
		
		N = S.nextInt();
		K = S.nextInt();
		
		X = new int[N];
		Y = new int[N];
		HP = new int[N];
		for (int i = 0; i < N; i++) {
			X[i] = S.nextInt() + 500;
			Y[i] = S.nextInt() + 500;
			HP[i] = S.nextInt();
		}
		
		AX = new int[K];
		AY = new int[K];
		W = new int[K];
		H = new int[K];
		D = new int[K];
		for (int i = 0; i < K; i++) {
			AX[i] = S.nextInt() + 500;
			AY[i] = S.nextInt() + 500;
			W[i] = S.nextInt();
			H[i] = S.nextInt();
			D[i] = S.nextInt();
		}
		
		solve();
	}
}
0