Cod sursa(job #51258)
| Utilizator | Data | 10 aprilie 2007 17:49:56 | |
|---|---|---|---|
| Problema | Aprindere | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.52 kb |
#include<stdio.h>
int n,m,i,x[1010],a[1010],c,j,y[1010][102];
long int timp,t[1000];
int main()
{
FILE *f,*g;
f=fopen("aprindere.in","r");
g=fopen("aprindere.out","w");
fscanf(f,"%d%d",&n,&m);
for(i=0;i<n;i++)
fscanf(f,"%d",&x[i]);
for(i=1;i<=m;i++)
{ fscanf(f,"%d%ld%d",&c,&t[c],&a[c]);
for(j=1;j<=a[c];j++)
fscanf(f,"%d",&y[c][j]);
}
for(i=0;i<n;i++)
if(x[i])
{timp+=t[i];
for(j=1;j<=a[c];j++)
x[y[c][j]]=1-x[y[c][j]];
}
fprintf(g,"%ld\n",timp);
fcloseall();
return 0;
}