Pagini recente » Cod sursa (job #1852274) | Cod sursa (job #1130477) | Cod sursa (job #1471325) | Cod sursa (job #2623868) | Cod sursa (job #3274645)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("aprindere.in");
ofstream fout("aprindere.out");
/**
0 1 0 0 1
0 3 2 0 2
1 3 2 1 2
3 1 2 3 4
4 2 1 4
1 2 2 1 3
*/
int n, m, c, nrc, t, fr[1001];
struct val
{
int timp, nr, cam[1001];
}b[1001];
int main()
{
int i, j, x, Ttotal = 0, cnt;
fin >> n >> m;
for (i = 0 ; i < n ; i++)
{
fin >> x;
if (x == 1)
++fr[i];
}
for (i = 1 ; i <= m ; i++)
{
fin >> c >> t >> nrc;
Ttotal += t;
b[c].timp = t; b[c].nr = nrc;
for (j = 1 ; j <= nrc ; j++)
{
fin >> x;
++fr[x];
b[c].cam[j] = x;
}
}
for (i = 0 ; i < n ; i++)
{
cnt = 0;
for (j = 1 ; j <= b[i].nr ; j++)
if (fr[b[i].cam[j]] % 2 == 0)
++cnt;
if (cnt == b[i].nr)
Ttotal -= b[i].timp;
}
fout << Ttotal;
return 0;
}