Cod sursa(job #2037184)

Utilizator GoogalAbabei Daniel Googal Data 11 octombrie 2017 20:44:26
Problema Aprindere Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.75 kb
#include <iostream>
#include <fstream>
#include <bitset>

using namespace std;

ifstream in("aprindere.in");
ofstream out("aprindere.out");

const int NMAX = 1000;

int n, m, res;
bitset <1 + NMAX> ap;

int main()
{
  in >> n >> m;
  for(int i = 0; i < n; i++) {
    int light;
    in >> light;
    ap[i] = light;
  }

  for(int i = 1; i <= m; i++) {
    int room, time, no;
    in >> room >> time >> no;
    if(ap[room] == 0) {
      res += time;
      for(int j = 1; j <= no; j++) {
        int x;
        in >> x;
        ap[x] = 1 - ap[x];
      }
    } else {
      for(int j = 1; j <= no; j++) {
        int x;
        in >> x;
      }
    }
  }

  out << res << '\n';

  in.close();
  out.close();

  return 0;
}