結果
問題 | No.1490 スライムと爆弾 |
ユーザー | tenten |
提出日時 | 2021-04-30 08:57:48 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 482 ms / 2,000 ms |
コード長 | 2,604 bytes |
コンパイル時間 | 2,698 ms |
コンパイル使用メモリ | 74,832 KB |
実行使用メモリ | 107,544 KB |
最終ジャッジ日時 | 2023-09-25 09:38:23 |
合計ジャッジ時間 | 14,239 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 43 ms
49,280 KB |
testcase_01 | AC | 42 ms
49,476 KB |
testcase_02 | AC | 45 ms
49,372 KB |
testcase_03 | AC | 47 ms
49,748 KB |
testcase_04 | AC | 48 ms
49,776 KB |
testcase_05 | AC | 45 ms
49,204 KB |
testcase_06 | AC | 48 ms
49,332 KB |
testcase_07 | AC | 52 ms
49,472 KB |
testcase_08 | AC | 46 ms
49,280 KB |
testcase_09 | AC | 48 ms
49,384 KB |
testcase_10 | AC | 51 ms
49,336 KB |
testcase_11 | AC | 46 ms
49,324 KB |
testcase_12 | AC | 46 ms
49,332 KB |
testcase_13 | AC | 413 ms
79,532 KB |
testcase_14 | AC | 392 ms
75,236 KB |
testcase_15 | AC | 327 ms
78,716 KB |
testcase_16 | AC | 329 ms
67,140 KB |
testcase_17 | AC | 290 ms
72,848 KB |
testcase_18 | AC | 409 ms
81,068 KB |
testcase_19 | AC | 391 ms
78,572 KB |
testcase_20 | AC | 340 ms
79,096 KB |
testcase_21 | AC | 275 ms
71,140 KB |
testcase_22 | AC | 369 ms
72,920 KB |
testcase_23 | AC | 43 ms
49,764 KB |
testcase_24 | AC | 43 ms
49,292 KB |
testcase_25 | AC | 441 ms
86,776 KB |
testcase_26 | AC | 447 ms
86,860 KB |
testcase_27 | AC | 458 ms
88,848 KB |
testcase_28 | AC | 416 ms
107,544 KB |
testcase_29 | AC | 388 ms
104,464 KB |
testcase_30 | AC | 482 ms
105,396 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(); } }