結果
問題 | No.60 魔法少女 |
ユーザー | Grenache |
提出日時 | 2016-05-18 07:59:27 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 614 ms / 5,000 ms |
コード長 | 2,457 bytes |
コンパイル時間 | 4,412 ms |
コンパイル使用メモリ | 78,988 KB |
実行使用メモリ | 54,324 KB |
最終ジャッジ日時 | 2024-10-06 05:26:19 |
合計ジャッジ時間 | 10,034 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 104 ms
45,652 KB |
testcase_01 | AC | 100 ms
45,964 KB |
testcase_02 | AC | 89 ms
46,020 KB |
testcase_03 | AC | 85 ms
45,812 KB |
testcase_04 | AC | 463 ms
53,996 KB |
testcase_05 | AC | 428 ms
52,208 KB |
testcase_06 | AC | 614 ms
52,600 KB |
testcase_07 | AC | 475 ms
51,296 KB |
testcase_08 | AC | 382 ms
54,144 KB |
testcase_09 | AC | 257 ms
50,600 KB |
testcase_10 | AC | 603 ms
54,324 KB |
testcase_11 | AC | 211 ms
45,740 KB |
testcase_12 | AC | 358 ms
52,388 KB |
testcase_13 | AC | 538 ms
53,984 KB |
ソースコード
import java.io.*; import java.util.*; public class Main_yukicoder60 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); Printer pr = new Printer(System.out); final int MAX = 1001; int n = sc.nextInt(); int k = sc.nextInt(); int[] x = new int[n]; int[] y = new int[n]; int[] hp = new int[n]; for (int i = 0; i < n; i++) { x[i] = sc.nextInt() + 500; y[i] = sc.nextInt() + 500; hp[i] = sc.nextInt(); } int[][] mat = new int[MAX + 1][MAX + 1]; for (int i = 0; i < k; i++) { int ax = sc.nextInt() + 500; int ay = sc.nextInt() + 500; int w = sc.nextInt(); int h = sc.nextInt(); int d = sc.nextInt(); mat[ay][ax] += d; mat[ay][Math.min(MAX, ax + w + 1)] -= d; mat[Math.min(MAX, ay + h + 1)][ax] -= d; mat[Math.min(MAX, ay + h + 1)][Math.min(MAX, ax + w + 1)] += d; } for (int i = 0; i <= MAX; i++) { for (int j = 1; j <= MAX; j++) { mat[i][j] += mat[i][j - 1]; } } for (int i = 1; i <= MAX; i++) { for (int j = 0; j <= MAX; j++) { mat[i][j] += mat[i - 1][j]; } } int ret = 0; for (int i = 0; i < n; i++) { int tmp = hp[i] - mat[y[i]][x[i]]; if (tmp > 0) { ret += tmp; } } pr.println(ret); // for (int i = 0; i <= MAX; i++) { // for (int j = 0; j <= MAX; j++) { // pr.print(mat[i][j]); // pr.print(" "); // } // pr.println(); // } pr.close(); sc.close(); } @SuppressWarnings("unused") private static class Scanner { BufferedReader br; Iterator<String> it; Scanner (InputStream in) { br = new BufferedReader(new InputStreamReader(in)); } String next() throws RuntimeException { try { if (it == null || !it.hasNext()) { it = Arrays.asList(br.readLine().split(" ")).iterator(); } return it.next(); } catch (IOException e) { throw new IllegalStateException(); } } int nextInt() throws RuntimeException { return Integer.parseInt(next()); } long nextLong() throws RuntimeException { return Long.parseLong(next()); } float nextFloat() throws RuntimeException { return Float.parseFloat(next()); } double nextDouble() throws RuntimeException { return Double.parseDouble(next()); } void close() { try { br.close(); } catch (IOException e) { // throw new IllegalStateException(); } } } private static class Printer extends PrintWriter { Printer(PrintStream out) { super(out); } } }