Pagini recente » Cod sursa (job #377345) | Cod sursa (job #2496136) | Cod sursa (job #1887564) | Cod sursa (job #2751072) | Cod sursa (job #2495504)
#include <bits/stdc++.h>
using namespace std;
ifstream fin ("aprindere.in");
ofstream fout ("aprindere.out");
const int N = 1005;
bool f[N];
void usain_bolt()
{
ios::sync_with_stdio(false);
cin.tie(0);
}
int main()
{
usain_bolt();
int n, m, sol = 0;
fin >> n >> m;
for(int i = 0; i < n; ++i) {
bool type;
fin >> type;
f[i] ^= type;
}
for(int i = 1; i <= m; ++i) {
int room, price, rooms;
fin >> room >> price >> rooms;
bool ok = (f[room] == 0);
if(ok == true) sol += price;
for(int i = 1; i <= rooms; ++i) {
int nextt;
fin >> nextt;
f[nextt] ^= ok;
}
}
fout << sol;
return 0;
}