Pagini recente » Cod sursa (job #2414411) | Cod sursa (job #2217606) | Cod sursa (job #1352188) | Cod sursa (job #1006015) | Cod sursa (job #2168017)
#include <fstream>
using namespace std;
ifstream f("aprindere.in");
ofstream g("aprindere.out");
struct nani
{
int t,nr;
}v[1001];
int c[1005][1005],n,m,bec[1001],ca,i,j,rez;
int main()
{
f>>n>>m;
for (i=0;i<n;i++)
{
f>>bec[i];
}
for (i=1;i<=m;i++)
{
f>>ca;
f>>v[ca].t>>v[ca].nr;
for (j=1;j<=v[ca].nr;j++)
{
f>>c[ca][j];
}
}
rez=0;
for (i=0;i<n;i++)
{
if (bec[i]==0)
{
rez+=v[i].t;
for (j=1;j<=v[i].nr;j++)
{
bec[c[i][j]]=1-bec[c[i][j]];
}
}
}
g<<rez;
return 0;
}