Cod sursa(job #300770)

Utilizator stefynr8Space Monkey stefynr8 Data 7 aprilie 2009 17:47:13
Problema Aprindere Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.16 kb
#include<stdio.h>
#define nmax 1001
int m,n,i,j,timp,a[nmax][nmax],c,t[nmax],nr[nmax],v[nmax];

int main()
{
 freopen("aprindere.in","r",stdin);
 freopen("aprindere.out","w",stdout);
 
 scanf("%d %d", &n,&m);
 
 for(i=0;i<=n-1;i++)
    scanf("%d", &v[i]);
    
 for(i=1;i<=m;i++)
   {
   scanf("%d", &c);
   
   scanf("%d", &t[c]);
   
   scanf("%d", &nr[c]);
   
   for(j=1;j<=nr[c];j++)
       scanf("%d", &a[c][j]);
   }
 
                                                   
   
 for(i=0;i<=n-1;i++)
     {
      if(v[i]==0){ if(t[i]>=1){
                              timp+=t[i];
                              for(j=1;j<=nr[i];j++) 
                               if(v[a[i][j]]==0)
                                                  v[a[i][j]]=1;
                                           else  v[a[i][j]]=0;
                               }
                        else{
                             printf("nu e sol");
                             return 0;
                             } 
                  }           
     }
   
  printf("%d", timp);
  
 return 0;
}