Cod sursa(job #1324882)

Utilizator taigi100Cazacu Robert taigi100 Data 22 ianuarie 2015 21:25:33
Problema Aprindere Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.84 kb
/*
	Keep It Simple!
*/

#include <fstream>
#include <vector>

using namespace std;

const int kMax_N = 1005;

int n, m, dattime[kMax_N],result;
bool balls[kMax_N],c[kMax_N];
vector<int> G[kMax_N];

void ReadData()
{
	ifstream fin("aprindere.in");
	fin >> n >> m;
	for (int i = 0; i < n; ++i)
		fin >> balls[i];
	int x, y, z;

	for (int i = 1; i <= m; ++i)
	{
		fin >> x; fin >> dattime[x] >> y;
		c[x] = 1;
		for (int j = 1; j <= y; j++)
		{
			fin >> z;
			G[x].push_back(z);
		}
	}

	fin.close();
}

void PrintResult()
{
	ofstream fout("aprindere.out");
	fout << result;
	fout.close();
}

void Solve()
{
	ReadData();

	for (int i = 0; i < n;++i)
		if (!balls[i])
		{
			result += dattime[i];
			for (auto j : G[i])
				balls[j] ^= 1;
		}

	PrintResult();
}

int main()
{
	Solve();
	return 0;
}