結果
問題 | No.60 魔法少女 |
ユーザー |
![]() |
提出日時 | 2015-06-24 18:50:55 |
言語 | Java21 (openjdk 21) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,686 bytes |
コンパイル時間 | 1,742 ms |
コンパイル使用メモリ | 77,044 KB |
実行使用メモリ | 75,400 KB |
最終ジャッジ日時 | 2024-07-07 17:29:43 |
合計ジャッジ時間 | 12,242 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 126 ms
58,096 KB |
testcase_01 | AC | 123 ms
58,096 KB |
testcase_02 | AC | 134 ms
58,520 KB |
testcase_03 | AC | 140 ms
59,368 KB |
testcase_04 | RE | - |
testcase_05 | RE | - |
testcase_06 | RE | - |
testcase_07 | RE | - |
testcase_08 | RE | - |
testcase_09 | RE | - |
testcase_10 | RE | - |
testcase_11 | RE | - |
testcase_12 | RE | - |
testcase_13 | RE | - |
ソースコード
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++) { int x = AX[i], y = AY[i]; damage[y][x] = D[i]; if(x + W[i] + 1 <= 1000) { damage[y][x+W[i]+1] = -1 * D[i]; if(y+H[i]+1 <= 1000) { damage[y+H[i]+1][x+W[i]+i] = D[i]; } } if(y+H[i]+1 <= 1000) { damage[y+H[i]+1][x] = -1 * D[i]; } } for (int y = 0; y <= 1000; y++) { for (int x = 1; x <= 1000; x++) { damage[y][x] += damage[y][x-1]; } } for (int x = 0; x <= 1000; x++) { for (int y = 1; y <= 1000; y++) { damage[y][x] += damage[y-1][x]; } } 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(); } }