Pagini recente » Cod sursa (job #2831895) | Cod sursa (job #3174380) | Cod sursa (job #301006) | Cod sursa (job #483244) | Cod sursa (job #1077178)
#include <fstream>
#include <vector>
using namespace std ;
const int Nmax = 1002;
vector < int > List[Nmax];
bool v[Nmax];
int Cost[Nmax];
int main()
{
int i ,x , n, m, cost , room ,cnt ,Sol = 0;
ifstream f("aprindere.in");
f >> n >> m;
for(i = 0;i < n; ++i)
f >> v[i];
while(m--)
{
f >> room >> cost >> cnt;
Cost[room] = cost;
while(cnt--)
{
f >> x;
List[room].push_back(x);
}
}
f.close();
for(i = 0;i < n; ++i)
if(v[i]==0)
{
Sol += Cost[i];
for(vector < int > ::iterator it = List[i].begin(); it != List[i].end(); ++it)
v[*it] = v[*it]^1;
}
ofstream g("aprindere.out");
g<<Sol<<"\n";
g.close();
return 0;
}