Cod sursa(job #233150)

Utilizator alex23alexandru andronache alex23 Data 16 decembrie 2008 22:40:48
Problema Aprindere Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.08 kb
#include <iostream>
#include <vector>

using namespace std;

vector<int> a;
FILE *f = fopen("aprindere.in", "r"), *g = fopen("aprindere.out", "w");

int N, M;

int main()
 {
          
   fscanf(f, "%d %d\n", &N, &M);
   for (int i = 0; i < N; i++)
      {
            int x;
            fscanf(f, "%d", &x);
            a.push_back(x);
      }
   
   int timp = 0;   
   for (int j = 0; j < M; j++)
      { 
            int c, t, nr;
            fscanf(f, "%d %d %d", &c, &t, &nr);
            if (a[c] == 1)
                {for (int i = 0; i < nr; i++)
                     {int x;
                      fscanf(f, "%d", &x);
                     }
                }
            else
                {
                     timp += t;
                     for (int i = 0; i < nr; i++)
                         {int x;
                          fscanf(f, "%d", &x);
                          a[x] = !(a[x]); 
                         } 
                }
      }
      
   fclose(f);
   
   fprintf(g, "%d", timp);
   fclose(f);    
   
   return 0;
 }