Pagini recente » Cod sursa (job #2880734) | Cod sursa (job #400091) | Cod sursa (job #1443663) | Cod sursa (job #984892) | Cod sursa (job #125465)
Cod sursa(job #125465)
#include <fstream>
std::ifstream f1("inundatii.in");
std::ofstream f2("inundatii.out");
int main()
{
long n, i, x, y, z, x1, y1, z1;
unsigned long long sol=0;
f1>>n;
f1>>x>>y>>z;
for (i=1; i<n; i++)
{
f1>>x1>>y1>>z1;
if (x1<x)
{
sol+=x-x1+1;
x1=x+1;
}//if
if (y1<y)
{
sol+=y-y1+1;
y1=y+1;
}//if
if (z1<z)
{
sol+=z-z1+1;
z1=z+1;
}//if
x=x1;
y=y1;
z=z1;
}//for i
f2<<sol;
f1.close();
f2.close();
return 0;
}//main