Pagini recente » Cod sursa (job #1335962) | Cod sursa (job #1566248) | Cod sursa (job #1322133) | Cod sursa (job #863711) | Cod sursa (job #3232771)
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
using i64 = int64_t;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
// #ifdef LOCAL
ifstream cin{"inundatii.in"};
ofstream cout{"inundatii.out"};
// #endif
i64 n;
cin >> n;
i64 res = 0;
i64 x, y, z;
vector<vector<i64>> v(n);
for (i64 i = 0; i < n; i++) {
cin >> x >> y >> z;
v[i] = {x, y, z};
}
for (i64 j = 0; j < 3; j++) {
for (i64 i = 0; i < n; i++) {
if (i == 0) {
if (i + 1 == n) {
continue;
}
res += v[i][j] - v[i + 1][j] + 1;
v[i][j] = v[i + 1][j] - 1;
} else if (i < n / 2) {
res += (i + 1) * (v[i][j] - v[i + 1][j]);
v[i][j] = v[i + 1][j];
} else {
res += v[i - 1][j] - v[i][j] + 1;
v[i][j] = v[i - 1][j] + 1;
}
}
}
cout << res;
return 0;
}