結果
問題 | No.60 魔法少女 |
ユーザー |
![]() |
提出日時 | 2020-11-30 14:18:30 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 1,308 ms / 5,000 ms |
コード長 | 1,113 bytes |
コンパイル時間 | 2,531 ms |
コンパイル使用メモリ | 77,028 KB |
実行使用メモリ | 73,664 KB |
最終ジャッジ日時 | 2024-09-13 02:21:24 |
合計ジャッジ時間 | 15,734 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 10 |
ソースコード
import java.util.*; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); int[] xArr = new int[n]; int[] yArr = new int[n]; int[] hArr = new int[n]; for (int i = 0; i < n; i++) { xArr[i] = sc.nextInt() + 501; yArr[i] = sc.nextInt() + 501; hArr[i] = sc.nextInt(); } int[][] imos = new int[1010][1010]; for (int i = 0; i < k; i++) { int x = sc.nextInt() + 501; int y = sc.nextInt() + 501; int w = sc.nextInt(); int h = sc.nextInt(); int d = sc.nextInt(); imos[x][y] += d; imos[Math.min(x + w + 1, 1009)][y] -= d; imos[x][Math.min(y + h + 1, 1009)] -= d; imos[Math.min(x + w + 1, 1009)][Math.min(y + h + 1, 1009)] += d; } for (int i = 1; i < 1010; i++) { for (int j = 1; j < 1010; j++) { imos[i][j] += imos[i - 1][j] + imos[i][j - 1] - imos[i - 1][j - 1]; } } long ans = 0; for (int i = 0; i < n; i++) { ans += Math.max(0, hArr[i] - imos[xArr[i]][yArr[i]]); } System.out.println(ans); } }