Pagini recente » Monitorul de evaluare | Cod sursa (job #2547855) | Cod sursa (job #369997) | Cod sursa (job #1873000) | Cod sursa (job #1204952)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("aprindere.in");
ofstream fout("aprindere.out");
int n, m, c, tc, nrc, s;
int a[1001], room[1001];
int main()
{
fin >> n >> m;
for (int i = 0; i < n; i++)
fin >> a[i];
for (int i = 0; i < m; i++)
{
fin >> c >> tc >> nrc;
for (int j = 0; j < nrc; j++)
fin >> room[j];
if (a[c] == 0)
{
s = s + tc;
for (int j = 0; j < nrc; j++)
a[room[j]] = (a[room[j]] + 1) % 2;
}
}
fout << s;
fin.close();
fout.close();
return 0;
}