#include #include #include using namespace std; int arr[1001][1001]; int main(){ for(int i=0; i<1001; ++i){ for(int j=0; j<1001; ++j){ arr[i][j]=0; } } int n,k,x,y,hp,ax,ay,w,h,d; cin>>n>>k; vector> v; for(int i=0; i>x>>y>>hp; tuple t=make_tuple(x,y,hp); v.push_back(t); } for(int i=0; i>ax>>ay>>w>>h>>d; int sx,ex,sy,ey; sx=ax+500; ex=ax+500+w; if(ex>1000) ex=1000; sy=ay+500; ey=ay+500+h; if(ey>1000) ey=1000; for(int j=sx; j<=ex; ++j){ for(int k=sy; k<=ey; ++k){ arr[j][k]+=d; } } } int z=0; for(int i=0; i t=v[i]; int& tx=get<0>(t); int& ty=get<1>(t); int& thp=get<2>(t); int tx2=tx+500; int ty2=ty+500; int thp2=thp; thp2-=arr[tx2][ty2]; if(thp2<0) thp2=0; z+=thp2; } cout<