Cod sursa(job #1243225)

Utilizator MarcvsHdrMihai Leonte MarcvsHdr Data 15 octombrie 2014 18:05:57
Problema Aprindere Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.66 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;
}