Cod sursa(job #3232700)

Utilizator rockoanaOana Pasca rockoana Data 1 iunie 2024 09:47:41
Problema Inundatii Scor 0
Compilator cpp-64 Status done
Runda Simulare E4 #1 Marime 0.63 kb
#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{"input.txt"};
  ofstream cout{"output.txt"};
#endif

  i64 n;
  cin >> n;

  i64 res = 0;
  i64 x, y, z;
  i64 lx, ly, lz;
  for (i64 i = 0; i < n; i++) {
    cin >> x >> y >> z;
    if (i == 1) {
      res += lx - x + ly - y + lz - z + 3;
      lx = x, ly = y, lz = z;
    } else if (i > 0) {
      res += lx - x + ly - y + lz - z + 3;
      lx++, ly++, lz++;
    } else if (i == 0) {
      lx = x, ly = y, lz = z;
    }
  }

  cout << res;

  return 0;
}