結果
| 問題 |
No.60 魔法少女
|
| コンテスト | |
| ユーザー |
creep04
|
| 提出日時 | 2017-10-26 23:33:31 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,731 bytes |
| コンパイル時間 | 2,293 ms |
| コンパイル使用メモリ | 77,456 KB |
| 実行使用メモリ | 55,844 KB |
| 最終ジャッジ日時 | 2024-11-21 20:14:36 |
| 合計ジャッジ時間 | 7,452 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 8 WA * 2 |
ソースコード
import java.io.*;
import java.util.*;
public class Main {
static FastScanner sc;
public static void main(String[] args) {
sc = new FastScanner();
int N = sc.nextInt();
int K = sc.nextInt();
int ene[][] = new int[1001][1001]; // 敵のHPのマップ
int dif[][] = new int[1001][1001]; // 与ダメージのマップ
for (int i=0; i<N; i++) {
int x = sc.nextInt() + 500;
int y = sc.nextInt() + 500;
int hp = sc.nextInt();
ene[x][y] = hp; // -500〜500を0〜1000に
}
for (int i=0; i<K; i++) {
int x = sc.nextInt() + 500;
int y = sc.nextInt() + 500;
int wx = sc.nextInt();
int wy = sc.nextInt();
int d = sc.nextInt();
dif[x][y] = d;
if (x+wx+1<1000 && y+wy+1<1000) dif[x+wx+1][y+wy+1] = d;
if (x+wx+1<1000) dif[x+wx+1][y] = -d;
if (y+wy+1<1000) dif[x][y+wy+1] = -d;
}
for (int y=0; y<1000; y++) {
for (int x=1; x<1000; x++) {
dif[x][y] += dif[x-1][y];
}
}
for (int x=0; x<1000; x++) {
for (int y=1; y<1000; y++) {
dif[x][y] += dif[x][y-1];
}
}
int ans = 0;
for (int y=0; y<1000; y++) {
for (int x=0; x<1000; x++) {
if (ene[x][y]-dif[x][y]>0) ans += ene[x][y]-dif[x][y];
}
}
System.out.println(ans);
}
static class FastScanner {
BufferedReader br;
StringTokenizer st;
public FastScanner() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
}
}
creep04