結果
問題 | No.1490 スライムと爆弾 |
ユーザー | tenten |
提出日時 | 2021-04-30 08:57:48 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 491 ms / 2,000 ms |
コード長 | 2,604 bytes |
コンパイル時間 | 2,242 ms |
コンパイル使用メモリ | 77,680 KB |
実行使用メモリ | 104,460 KB |
最終ジャッジ日時 | 2024-07-18 07:51:14 |
合計ジャッジ時間 | 11,264 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 45 ms
50,320 KB |
testcase_01 | AC | 47 ms
50,360 KB |
testcase_02 | AC | 48 ms
49,992 KB |
testcase_03 | AC | 50 ms
50,348 KB |
testcase_04 | AC | 52 ms
50,180 KB |
testcase_05 | AC | 50 ms
50,344 KB |
testcase_06 | AC | 49 ms
49,852 KB |
testcase_07 | AC | 51 ms
50,060 KB |
testcase_08 | AC | 47 ms
50,220 KB |
testcase_09 | AC | 50 ms
50,328 KB |
testcase_10 | AC | 49 ms
50,232 KB |
testcase_11 | AC | 48 ms
50,084 KB |
testcase_12 | AC | 48 ms
50,084 KB |
testcase_13 | AC | 329 ms
74,084 KB |
testcase_14 | AC | 370 ms
74,020 KB |
testcase_15 | AC | 297 ms
75,836 KB |
testcase_16 | AC | 302 ms
67,016 KB |
testcase_17 | AC | 263 ms
70,364 KB |
testcase_18 | AC | 360 ms
78,740 KB |
testcase_19 | AC | 348 ms
77,784 KB |
testcase_20 | AC | 320 ms
74,064 KB |
testcase_21 | AC | 264 ms
69,948 KB |
testcase_22 | AC | 349 ms
71,340 KB |
testcase_23 | AC | 50 ms
49,872 KB |
testcase_24 | AC | 46 ms
49,960 KB |
testcase_25 | AC | 411 ms
86,528 KB |
testcase_26 | AC | 390 ms
86,132 KB |
testcase_27 | AC | 402 ms
86,688 KB |
testcase_28 | AC | 402 ms
102,900 KB |
testcase_29 | AC | 395 ms
91,504 KB |
testcase_30 | AC | 491 ms
104,460 KB |
ソースコード
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int h = sc.nextInt(); int w = sc.nextInt(); int n = sc.nextInt(); int m = sc.nextInt(); int[] tops = new int[n]; int[] unders = new int[n]; int[] lefts = new int[n]; int[] rights = new int[n]; int[] lives = new int[n]; for (int i = 0; i < n; i++) { tops[i] = sc.nextInt(); unders[i] = sc.nextInt(); lefts[i] = sc.nextInt(); rights[i] = sc.nextInt(); lives[i] = sc.nextInt(); } long[][] field = new long[h + 2][w + 2]; for (int i = 0; i < m; i++) { int row = sc.nextInt(); int col = sc.nextInt(); int b = sc.nextInt(); int power = sc.nextInt(); int startR = Math.max(1, row - b); int startC = Math.max(1, col - b); int endR = Math.min(h, row + b); int endC = Math.min(w, col + b); field[startR][startC] += power; field[endR + 1][startC] -= power; field[startR][endC + 1] -= power; field[endR + 1][endC + 1] += power; } for (int i = 1; i <= h; i++) { for (int j = 1; j <= w; j++) { field[i][j] += field[i - 1][j] + field[i][j - 1] - field[i - 1][j - 1]; } } for (int i = 1; i <= h; i++) { for (int j = 1; j <= w; j++) { field[i][j] += field[i - 1][j] + field[i][j - 1] - field[i - 1][j - 1]; } } int count = 0; for (int i = 0; i < n; i++) { long total = field[unders[i]][rights[i]] - field[tops[i] - 1][rights[i]] - field[unders[i]][lefts[i] - 1] + field[tops[i] - 1][lefts[i] - 1]; if (total < lives[i]) { count++; } } System.out.println(count); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public String next() throws Exception { if (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }