#include <cstdio>
#include <map>
#define superfast
#ifdef superfast
static char buf[1000000], *p1 = buf, *p2 = buf, obuf[1000000], *p3 = obuf;
#define getchar() p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin), p1 == p2) ? EOF : *p1++
#define putchar(x) (p3 - obuf < 1000000) ? (*p3 ++= x) : (fwrite(obuf, p3 - obuf, 1, stdout), p3 = obuf, *p3 ++= x)
#endif
namespace quick_IO{
template <typename type> inline void read(type &x){
x = 0;
int neg (1);
char c = getchar();
while(c < '0' || c > '9'){
if(c == '-')
neg = -1;
c = getchar();
}
while(c >= '0' && c <= '9'){
x = (x << 1) + (x << 3) + (c ^ 48);
c = getchar();
}
x *= neg;
}
static char cc[20];
template <typename type> inline void write(type x){
if(x == 0)
putchar(48);
int len = 0;
if(x < 0){
x = -x;
putchar('-');
}
while(x){
cc[len++] = x % 10 + '0';
x /= 10;
}
while(len--)
putchar(cc[len]);
}
template <typename type> inline void write(type x, char c){
if(x == 0)
putchar(48);
int len = 0;
if(x < 0){
x = -x;
putchar('-');
}
while(x){
cc[len++] = x % 10 + '0';
x /= 10;
}
while(len--)
putchar(cc[len]);
putchar(c);
}
}
using namespace quick_IO;
using std :: map;
const int dir[10][2] = {
{0, 0},
{-1, 0},
{0, 1},
{1, 0},
{0, -1}
};
#define int unsigned __int128
int n;
int x, y;
int z;
int res = 0;
bool f[10]; //自上右下左
int h, tmp, sub;
struct pair{
int first, second;
pair(int x = 0,int y = 0) : first(x), second(y){}
};
map <pair, int> coor;
inline bool operator <(const pair x, const pair ano){
if(x.first != ano.first)
return x.first < ano.first;
return x.second < ano.second;
}
inline pair make_pair(int x, int y){
return pair(x, y);
}
inline int min(int x, int y){
return x < y ? x : y;
}
signed main(){
read(n);
for(int i = 1; i <= n; i++){
read(x), read(y), read(z);
for(int i = 0; i < 5; i++)
f[i] = (coor.find(make_pair(x + dir[i][0], y + dir[i][1])) != coor.end());
res += 4 * z;
h = coor.find(make_pair(x, y)) -> second;
for(int i = 1; i < 5; i++)
if(f[i]){
tmp = coor.find(make_pair(x + dir[i][0], y + dir[i][1])) -> second;
if(tmp <= h)
continue;
sub = min(tmp - h, z);
res -= sub * 2;
}
write(res, 10);
coor[make_pair(x, y)] += z;
}
#ifdef superfast
fwrite(obuf, p3 - obuf, 1, stdout);
#endif
return 0;
}
谢谢!