Cod sursa(job #588910)

Utilizator a_h1926Heidelbacher Andrei a_h1926 Data 9 mai 2011 23:21:19
Problema Plus Scor 25
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.98 kb
#include <iostream>
#include <fstream>

using namespace std;

long long N[3], V[3], MUnu, Zero, Unu, S, A;

void Read ()
{
	ifstream fin ("plus.in");
	fin >> S >> N[0] >> V[0] >> N[1] >> V[1] >> N[2] >> V[2];
	switch (V[0])
	{
		case -1: MUnu+=N[0];
				 break;
		case 0 : Zero+=N[0];
				 break;
		case 1 : Unu+=N[0];
				 break;
		default: break;
	}
	switch (V[1])
	{
		case -1: MUnu+=N[1];
				 break;
		case 0 : Zero+=N[1];
				 break;
		case 1 : Unu+=N[1];
				 break;
		default: break;
	}
	switch (V[2])
	{
		case -1: MUnu+=N[2];
				 break;
		case 0 : Zero+=N[2];
				 break;
		case 1 : Unu+=N[2];
				 break;
		default: break;
	}
	fin.close ();
}

void Type ()
{
	ofstream fout ("plus.out");
	fout << A << "\n";
	fout.close ();
}

long long Min (long long a, long long b)
{
	if (a>b)
	{
		return b;
	}
	return a;
}

int main ()
{
	Read ();
	if (S!=0)
	{
		Unu-=S;
	}
	A=(1+Min (Unu, MUnu))*(1+Zero);
	Type ();
	return 0;
}