Pagini recente » Cod sursa (job #2804249) | Cod sursa (job #717118) | Cod sursa (job #2399346) | Cod sursa (job #3137537) | Cod sursa (job #2491375)
#include<iostream>
#include<fstream>
#include<algorithm>
#include<cmath>
using namespace std;
ifstream f("aprindere.in");
ofstream g("aprindere.out");
int k = 0;
int main()
{
int x;
int n,m;
int v[1005] = {0};
int c, tc, nrc;
f >> n >> m;
int i = 0;
while(i < n)
{
int a;
f >> a;
v[i] = a;
i++;
}
for(int i = 1; i <= m; i++)
{
f >> c >> tc >> nrc;
if(v[c] != 0)
{
for(int p = 1; p <= nrc; p++)
f >> x;
}
else if(v[c] == 0)
{
k = k + tc;
for(int p = 1; p <= nrc; p++)
{
f >> x;
if(v[x] != 1)
v[x] = 1;
else if(v[x] == 1)
v[x] = 0;
}
}
}
g << k;
}