Cod sursa(job #1307437)

Utilizator wGEORGEWGeorge Cioti wGEORGEW Data 2 ianuarie 2015 09:30:05
Problema Aprindere Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.7 kb
#include <iostream>
#include <fstream>
 
#include <bitset>
 
int main()
{
  std::ifstream in("aprindere.in");
  std::ofstream out("aprindere.out");
 
  std::bitset<1000> bits;
 
  int n, m;
  in >> n >> m;
  for (int i = 0; i < n; ++i) {
    int x;
    in >> x;
    if (x) {
      bits.flip(i);
    }
  }
 
  int totalt = 0;
  for (int i = 0; i < m; ++i) {
    int c, t, nr, camere[101];
    in >> c >> t >> nr;
    for (int j = 0; j < nr; ++j) {
      in >> camere[j];
    }
    if (!bits[c]) {
      totalt += t;
      for (int j = 0; j < nr; ++j) {
        bits.flip(camere[j]);
      }
    }
  }
 
  out << totalt << std::endl;
 
  in.close();
  out.close();
 
  return 0;
}