結果

問題 No.60 魔法少女
ユーザー IL_mstaIL_msta
提出日時 2015-07-13 11:36:08
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 72 ms / 5,000 ms
コード長 1,609 bytes
コンパイル時間 876 ms
コンパイル使用メモリ 84,680 KB
実行使用メモリ 8,652 KB
最終ジャッジ日時 2023-09-22 15:14:04
合計ジャッジ時間 3,388 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
7,740 KB
testcase_01 AC 6 ms
7,524 KB
testcase_02 AC 6 ms
7,448 KB
testcase_03 AC 6 ms
7,536 KB
testcase_04 AC 41 ms
7,652 KB
testcase_05 AC 44 ms
8,404 KB
testcase_06 AC 69 ms
8,452 KB
testcase_07 AC 52 ms
8,076 KB
testcase_08 AC 37 ms
7,928 KB
testcase_09 AC 18 ms
7,612 KB
testcase_10 AC 66 ms
8,652 KB
testcase_11 AC 12 ms
7,708 KB
testcase_12 AC 31 ms
8,284 KB
testcase_13 AC 72 ms
8,640 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
 
#include <iostream>
#include <iomanip>
 
#include <algorithm>
#include <cmath>
 
#include <string>
//#include <array>
#include <list>
#include <queue>
#include <vector>
#include <complex>
#include <set>
#include <map>
 
/////////
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;
 
#define PII pair<int,int>
/////////
typedef long long LL;
typedef long double LD;
/////////
using namespace::std;
/////////
const int KMax = 100000;
int Ex[KMax],Ey[KMax],EH[KMax];
int tiles[1001][1001];

int main(void){
    std::cin.tie(0); 
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed;//
    //cout << setprecision(10);//
	
	int N,K;
	int x,y,w,h,d;
	cin>>N>>K;
	rep(i,N){
		cin>>x>>y>>EH[i];
		Ex[i] = x+500;
		Ey[i] = y+500;
	}
	rep(i,K){
		cin>>x>>y>>w>>h>>d;
		x += 500;
		y += 500;
		tiles[y][x] += d;
		if(x+w+1 <= 1000){
		tiles[y][x+w+1] -= d;
		}
		if(y+h+1 <= 1000){
			tiles[y+h+1][x] -= d;
		}
		if( x+w+1 <= 1000 && y+h+1 <= 1000){
			tiles[y+h+1][x+w+1] += d;
		}
	}
	//横
	for(int Y = 0; Y <= 1000; ++Y){
		for(int X = 1; X <= 1000; ++X){
			tiles[Y][X] += tiles[Y][X-1];
		}
	}
	//縦
	for(int Y = 1; Y <= 1000; ++Y){
		for(int X = 0; X <= 1000; ++X){
			tiles[Y][X] += tiles[Y-1][X];
		}
	}
	////
	/*
	for(int Y=490; Y <=500+10;++Y){
		for(int X=490; X <= 510; ++X){
			cout << tiles[Y][X] << " ";
		}
		cout << endl;
	}
	*/
	///////////
	int ans = 0;
	int temp;
	rep(i,N){
		//Ex[i],Ey[i],EH[i]
		temp = EH[i] - tiles[ Ey[i] ][ Ex[i] ];
		if(temp > 0){
			ans += temp;
		}
	}
	P(ans);
    return 0;
}
0