Pagini recente » Cod sursa (job #643529) | Cod sursa (job #3183114) | Cod sursa (job #2800437) | Cod sursa (job #1253496) | Cod sursa (job #2106669)
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi first
#define se second
#define sz size
#define pb push_back
#define mp make_pair
#define bg begin
#define nd end
using namespace std;
#define int long long
const int maxn = 100003;
const int maxk = 1003;
int n,m;
int light[maxk];
int cst[maxk];
vector<int> g[maxk];
int32_t main(){
freopen("aprindere.in","r",stdin);
freopen("aprindere.out","w",stdout);
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> n >> m;
int room,t,nrc,x;
for(int i=0;i<n;++i) cin >> light[i];
for(int i=0;i<m;++i) {
cin >> room >> t >> nrc;
cst[room] = t;
for(int j=0;j<nrc;++j) {
cin >> x;
g[room].pb(x);
}
}
int ans = 0;
for(int i=0;i<n;++i) {
if(light[i]) continue;
ans += cst[i];
for(int ch : g[i]) light[ch] ^= 1;
}
cout << ans << '\n';
return 0;
}