Pagini recente » Cod sursa (job #561552) | Cod sursa (job #1381372) | Cod sursa (job #554498) | Cod sursa (job #1880169) | Cod sursa (job #1136089)
#include<fstream>
using namespace std;
ifstream f("aprindere.in");
ofstream g("aprindere.out");
int n, m, stare[1010], timp[1010], mod[1010][1010];
void Citeste()
{
int i, j, nr, c, x;
f>>n>>m;
for (i=0; i<n; ++i) f>>stare[i];
for (i=1; i<=m; ++i)
{
f>>c;
f>>timp[c]>>nr;
for (j=1; j<=nr; ++j)
{
f>>x;
mod[c][x]=1;
}
}
}
void Solve()
{
int i, j, sum=0;
for (i=0; i<n; ++i)
if (!stare[i])
{
sum+=timp[i];
for (j=0; j<n; ++j)
stare[j]^=mod[i][j];
}
g<<sum<<"\n";
}
int main()
{
Citeste();
Solve();
f.close();
g.close();
return 0;
}