Mai intai trebuie sa te autentifici.
Cod sursa(job #7218)
Utilizator | Data | 21 ianuarie 2007 13:07:40 | |
---|---|---|---|
Problema | Aprindere | Scor | 0 |
Compilator | cpp | Status | done |
Runda | preONI 2007, Runda 1, Clasa a 9-a si gimnaziu | Marime | 0.54 kb |
#include<fstream.h>
int n,m,st[1000],c[1000],tc[1000],nrc[1000],nr[1000],i,j,gasit,s,t;
int main()
{
ifstream f("aprindere.in");
ofstream g("aprindere.out");
f>>n>>m;
for(i=0;i<n;i++)
f>>st[i];
for(j=0;j<m;j++)
{
gasit=1;
f>>c[j]>>tc[j]>>nrc[j];
for(i=0;i<nrc[j];i++)
{
f>>nr[i];
if(st[nr[i]]==0)
gasit=0;
}
if(gasit==0)
{
s=s+tc[j];
for(t=0;t<=nrc[j];t++)
if(st[nr[t]]==0)
st[nr[t]]=1;
else
st[nr[t]]=0;
}
}
g<<s;
return 0;
}