Cod sursa(job #125464)

Utilizator ada_sAda-Mihaela Solcan ada_s Data 20 ianuarie 2008 12:57:47
Problema Inundatii Scor 0
Compilator cpp Status done
Runda preONI 2008, Runda 3, Clasa a 10-a Marime 0.46 kb
#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