Cod sursa(job #3232702)

Utilizator rockoanaOana Pasca rockoana Data 1 iunie 2024 09:49:34
Problema Inundatii Scor 0
Compilator cpp-64 Status done
Runda Simulare E4 #1 Marime 0.65 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{"inundatii.in"};
  ofstream cout{"inundatii.out"};
  // #endif

  i64 n;
  cin >> n;

  i64 res = 0;
  i64 x, y, z;
  i64 lx = 0, ly = 0, lz = 0;
  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;
}