Cod sursa(job #2970534)
Utilizator | Dorde Matei Dorde | Data | 25 ianuarie 2023 14:56:36 |
---|---|---|---|
Problema | Inundatii | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.43 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("inundatii.in");
ofstream fout("inundatii.out");
int n , x , y , z , lx , ly , lz ;
long long ans;
int main()
{
fin >> n >> lx >> ly >> lz;
for(int i = 2 ; i <= n ; ++ i){
fin >> x >> y >> z;
--x , --y , --z;
ans += abs(x - lx) + abs(y - ly) + abs(z - lz);
++lx , ++ly , ++lz;
}
fout << ans << '\n';
return 0;
}