結果

問題 No.60 魔法少女
ユーザー 37zigen37zigen
提出日時 2016-05-04 16:46:16
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,055 bytes
コンパイル時間 2,585 ms
コンパイル使用メモリ 77,644 KB
実行使用メモリ 105,040 KB
最終ジャッジ日時 2024-04-15 11:21:00
合計ジャッジ時間 18,470 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 247 ms
76,444 KB
testcase_01 AC 242 ms
76,384 KB
testcase_02 AC 248 ms
76,240 KB
testcase_03 AC 248 ms
76,652 KB
testcase_04 AC 1,354 ms
104,496 KB
testcase_05 AC 1,383 ms
101,472 KB
testcase_06 AC 1,630 ms
104,000 KB
testcase_07 AC 1,463 ms
101,900 KB
testcase_08 AC 1,286 ms
103,408 KB
testcase_09 AC 867 ms
98,656 KB
testcase_10 AC 1,576 ms
102,196 KB
testcase_11 WA -
testcase_12 AC 1,233 ms
100,724 KB
testcase_13 AC 1,653 ms
105,040 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder;
import java.util.Scanner;
public class Main{
	public static void main(String[] args)throws Exception{
		new Main().solve();
	}
	void solve(){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int k=sc.nextInt();
		int[][] table=new int[2000][2000];
		for(int i=0;i<n;i++){
			int x=sc.nextInt()+500;
			int y=sc.nextInt()+500;
			int hp=sc.nextInt();
			table[y][x]+=hp;
		}
		int[][] damage=new int[2000][2000];
		for(int i=0;i<k;i++){
			int x=sc.nextInt()+500;
			int y=sc.nextInt()+500;
			int w=sc.nextInt();
			int h=sc.nextInt();
			int d=sc.nextInt();
			damage[y][x]+=d;damage[y][x+w+1]=-d;
			damage[y+h+1][x]-=d;damage[y+h+1][w+x+1]+=d;
		}
		for(int i=0;i<=1000;i++){
			for(int j=1;j<=1000;j++){
				damage[i][j]+=damage[i][j-1];
			}
		}
		for(int i=0;i<=1000;i++){
			for(int j=1;j<=1000;j++){
				damage[j][i]+=damage[j-1][i];
			}
		}
		long res=0;
		for(int i=0;i<1000;i++){
			for(int j=0;j<1000;j++){
				if(table[i][j]>damage[i][j])res+=table[i][j]-damage[i][j];
			}
		}
		System.out.println(res);
	}
}
0