Pagini recente » Cod sursa (job #2096208) | Cod sursa (job #715571) | Cod sursa (job #1400044) | Cod sursa (job #1025620) | Cod sursa (job #2801671)
#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;
}