結果

問題 No.60 魔法少女
ユーザー HAHAHAHAHAHA
提出日時 2014-11-17 20:57:13
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 185 ms / 5,000 ms
コード長 1,201 bytes
コンパイル時間 805 ms
コンパイル使用メモリ 73,052 KB
実行使用メモリ 11,416 KB
最終ジャッジ日時 2023-08-30 20:28:30
合計ジャッジ時間 3,209 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
9,364 KB
testcase_01 AC 10 ms
9,260 KB
testcase_02 AC 9 ms
9,264 KB
testcase_03 AC 8 ms
9,524 KB
testcase_04 AC 103 ms
11,124 KB
testcase_05 AC 111 ms
11,284 KB
testcase_06 AC 180 ms
11,416 KB
testcase_07 AC 133 ms
11,180 KB
testcase_08 AC 88 ms
11,124 KB
testcase_09 AC 41 ms
11,224 KB
testcase_10 AC 170 ms
11,176 KB
testcase_11 AC 25 ms
11,232 KB
testcase_12 AC 77 ms
11,124 KB
testcase_13 AC 185 ms
11,260 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<sstream>
#include<cctype>
#include<cmath>
#include<algorithm>
using namespace std;

#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(j,m) for(int j=1;j<=m;j++)

typedef pair<int,int> P;
typedef vector<pair<int,int> > pii;
typedef map<string,int> mi;

const int N = 500;
int hp[1001][1001];
int dmg[1001][1001];

int main(){
	int n,k,sum=0;
	cin >> n >> k;
	rep(i,n){
		int x,y,h;
		cin >> x >> y >> h;
		hp[N+y][N+x] = h;
	}
	
	rep(i,k){
		int x,y,w,h,d;
		cin >> x >> y >> w >> h >> d;
		dmg[N+y][N+x] +=d;
		if(N+y+h+1<=1000) dmg[N+y+h+1][N+x] -=d;
		if(N+x+w+1<=1000) dmg[N+y][N+x+w+1] -=d;
		if(N+y+h+1<=1000 && N+x+w+1 <=1000) dmg[N+y+h+1][N+x+w+1] +=d;
	}
	rep(y,1001){
		rep(x,1000){
			dmg[y][x+1] += dmg[y][x];
		}
	}
	
	rep(y,1001){
		rep(x,1001){
			if(y<1000) dmg[y+1][x] += dmg[y][x];
			if(hp[y][x] > dmg[y][x]){
				sum+=hp[y][x]-dmg[y][x];
			}
		}
	}
	cout << sum << endl;
	return 0;
}
0