Cod sursa(job #2801671)

Utilizator MindralexMindrila Alex Mindralex Data 16 noiembrie 2021 18:57:40
Problema Aprindere Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.68 kb
#include <iostream>
#include <fstream>

using namespace std;

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

const int maxVal = 1001;

int main ()
{
  int n, m, i, timp_total = 0, j;
  bool v[maxVal];
  fin >> n >> m;
  for (i = 1; i <= n; i++) 
    fin >> v[i];
  for (i = 1; i <= m ; i++)
  {
    int camera, timp, numar_camere;
    fin >> camera >> timp >> numar_camere;
    int v_temp[maxVal];
    for (j = 1; j <= numar_camere; j++)
    {
      fin >> v_temp[j];
    }
    if (v[camera] == 0)
    {
      timp_total += timp;
      for (j = 1; j <= numar_camere; j++)
        v[v_temp[j]] = !(v[v_temp[j]]);
    }
    
  }
  fout << timp_total << '\n';
  return 0;           
}