Pagini recente » Cod sursa (job #540240) | Cod sursa (job #600240) | Istoria paginii runda/lot-2015-anime.edition | Cod sursa (job #585015) | Cod sursa (job #2878923)
#include <bits/stdc++.h>
using namespace std;
ifstream in ("aprindere.in");
ofstream out ("aprindere.out");
bitset<1001>v;
int main()
{
int n, m;
int time = 0;
in >> n >> m;
for (int i=0; i<n; i++)
{
bool x;
in >> x;
if (x)
v[i] = 1;
}
for (int i=1; i<=m; i++)
{
bool ok = false;
int c, t, nr;
in >> c >> t >> nr;
if (v[c] == 0)
{
time += t;
ok = true;
}
for (int j=1; j<=nr; j++)
{
int pos;
in >> pos;
if (ok)
v[pos] = 1 - v[pos];
}
}
out << time;
return 0;
}