結果

問題 No.60 魔法少女
ユーザー mukadenodaiou
提出日時 2018-03-30 11:49:12
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 241 ms / 5,000 ms
コード長 1,510 bytes
コンパイル時間 929 ms
コンパイル使用メモリ 104,508 KB
実行使用メモリ 37,320 KB
最終ジャッジ日時 2024-06-26 00:22:50
合計ジャッジ時間 4,401 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
using namespace std;
typedef long long int ll;
const int N = 1000000;
const int mod = 1000000007;
const int INF = 1 << 30;
#define rep(i,n) for(int i=(ll)0;i<(ll)n;++i)
#define ALL(x) x.begin(),x.end()
#define pp pair<ll,ll>
#define fi first
#define se second
ll ppow(ll x, ll n) {
	ll ans = 1;
	while (n > 0) {
		if ((n & 1) == 1)ans = ans + x;
		x = x * x;
		n >>= 1;
		ans %= mod;
	}
	return ans;
}
string YN(bool b) { return(b ? "YES" : "NO"); }
string yn(bool b) { return(b ? "Yes" : "No"); }
ll enemy[100000][3],m[2010][2010];//mは+1000して使う
int main(){
	ll n, k,sum=0;
	cin >> n >> k;
	rep(i, n)cin >> enemy[i][0] >> enemy[i][1] >> enemy[i][2];
	ll x, y, w, h, d;
	rep(i, k) {
		cin >> x >> y >> w >> h >> d;
		m[x + 1000][y + 1000] += d;
		m[x + 1000 + w + 1][y+1000] -= d;
		m[x + 1000][y + 1000 + h + 1] -= d;
		m[x + 1000 + w + 1][y + 1000 + h + 1] += d;
	}
	rep(j,2010)rep(i, 2010)if (i > 0)m[i][j] += m[i - 1][j];
	rep(i, 2010)rep(j, 2010)if (j > 0)m[i][j] += m[i][j - 1];
	rep(i, n) {
		sum += max((ll)0, enemy[i][2] - m[enemy[i][0] + 1000][enemy[i][1] + 1000]);
	}
	cout << sum << endl;
	return 0;
}
0