結果
| 問題 |
No.60 魔法少女
|
| コンテスト | |
| ユーザー |
TamuoTamuoTamuo
|
| 提出日時 | 2019-06-19 09:25:35 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 222 ms / 5,000 ms |
| コード長 | 1,883 bytes |
| コンパイル時間 | 842 ms |
| コンパイル使用メモリ | 80,064 KB |
| 実行使用メモリ | 21,348 KB |
| 最終ジャッジ日時 | 2024-11-30 08:00:59 |
| 合計ジャッジ時間 | 3,654 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 10 |
ソースコード
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<set>
#include<vector>
#include<map>
using namespace std;
#define REP(i, n, N) for(int i=(n); i<(N); i++)
#define RREP(i, n, N) for(int i=(N-1); i>=n; i--)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define v2(T) vector<vector<T>>
typedef long long ll;
const ll mod = 1e9 + 7;
const ll inf = 1e18;
#define CONVERT 500
int main(){
int n,k,ans=0;
int e_field[1510][1510];
int m_field[1510][1510];
REP(i,0,1510){
REP(j,0,1510){
e_field[i][j]=0;
m_field[i][j]=0;
}
}
cin >> n >> k;
//敵の位置と体力
REP(i,0,n){
int x,y,hp;
cin >> x >> y >> hp;
x += CONVERT;
y += CONVERT;
e_field[y][x] = hp;
}
//いもす法step1 累積和のための前処理
REP(i,0,k){
int ax,ay,w,h,d;
cin >> ax >> ay >> w >> h >> d;
ax += CONVERT;
ay += CONVERT;
m_field[ay][ax] += d;
m_field[ay+h+1][ax] -= d;
m_field[ay][ax+w+1] -= d;
m_field[ay+h+1][ax+w+1] += d;
}
//いもす法step2 累積和をとってダメージフィールドを作成
//x軸の累積和
REP(i,0,1510){
REP(j,0,1510){
if(j==0)continue;
m_field[i][j]+=m_field[i][j-1];
}
}
//y軸の累積和
REP(i,0,1510){
REP(j,0,1510){
if(i==0)continue;
m_field[i][j]+=m_field[i-1][j];
}
}
//体力がどれだけ残るか計算
int sub;
REP(i,0,1510){
REP(j,0,1510){
sub=e_field[i][j]-m_field[i][j];
ans+=max(0,sub);
}
}
p(ans);
}
TamuoTamuoTamuo