Pagini recente » Cod sursa (job #1606662) | Cod sursa (job #116283) | Cod sursa (job #63204) | Cod sursa (job #190309) | Cod sursa (job #346101)
Cod sursa(job #346101)
#include<fstream>
#define dmax 1002
using namespace std;
ifstream in("aprindere.in");
ofstream out("aprindere.out");
int n,m;
long ct;
bool mat[dmax];
int main()
{ int i,nr,c,ap,x,j,ok;
in>>n>>m;
for(i=0;i<n;i++)
in>>mat[i];
for(i=1;i<=m;i++)
{ in>>nr>>c>>ap;
ok=0;
if(!mat[nr])
ok=1;
for(j=1;j<=ap;j++)
{ in>>x;
if(ok==1)
mat[x]=(mat[x]+1)%2;
}
if(ok)
ct+=c;
}
in.close();
out<<ct;
out.close();
return 0;
}