結果

問題 No.60 魔法少女
ユーザー 37zigen37zigen
提出日時 2016-05-04 16:48:03
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,494 ms / 5,000 ms
コード長 1,057 bytes
コンパイル時間 2,297 ms
コンパイル使用メモリ 76,988 KB
実行使用メモリ 117,592 KB
最終ジャッジ日時 2024-04-15 11:21:18
合計ジャッジ時間 16,643 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 213 ms
86,048 KB
testcase_01 AC 212 ms
85,808 KB
testcase_02 AC 225 ms
86,016 KB
testcase_03 AC 222 ms
85,764 KB
testcase_04 AC 1,247 ms
116,308 KB
testcase_05 AC 1,260 ms
113,268 KB
testcase_06 AC 1,467 ms
116,104 KB
testcase_07 AC 1,319 ms
113,216 KB
testcase_08 AC 1,163 ms
115,392 KB
testcase_09 AC 829 ms
110,640 KB
testcase_10 AC 1,431 ms
113,880 KB
testcase_11 AC 664 ms
87,032 KB
testcase_12 AC 1,126 ms
113,212 KB
testcase_13 AC 1,494 ms
117,592 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