Pagini recente » Cod sursa (job #290306) | Cod sursa (job #2846534) | Cod sursa (job #2616347) | Cod sursa (job #220031) | Cod sursa (job #1424962)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("aprindere.in");
ofstream fout("aprindere.out");
const int NMax = 1005;
bool bec[NMax];
int room[NMax];
int main()
{
int n,m;
fin >> n >> m;
for(int i = 0; i < n; i++){
fin >> bec[i];
}
int r,time,num,total_time = 0;
for(int i = 1; i <= m; i++){
fin >> r >> time >> num;
for(int j = 1; j <= num; j++){
fin >> room[j];
}
if(!bec[r]){
total_time += time;
for(int j = 1; j <= num; j++){
bec[room[j]] ^= 1;
}
}
}
fout << total_time;
return 0;
}