#define PROBLEM "https://yukicoder.me/problems/no/60" #include #include #include template struct imos2D{ int H, W; std::vector> data; imos2D(int h, int w): H(h), W(w){ data.resize(H+10, std::vector(W+10)); } // [y0, y1) * [x0, x1) void add(int y0, int x0, int y1, int x1, T x) { data[y0][x0] += x; data[y1][x1] += x; data[y0][x1] -= x; data[y1][x0] -= x; } void build() { for(int i=0; i> N >> K; std::vector x(N), y(N), hp(N); for(int i=0; i> x[i] >> y[i] >> hp[i]; x[i] += 500; y[i] += 500; } imos2D grid(1500, 1500); for(int i=0; i> ax >> ay >> w >> h >> d; ax += 500; ay += 500; grid.add(ay, ax, ay+h+1, ax+w+1, d); } grid.build(); int ans = 0; for(int i=0; i