Pagini recente » Cod sursa (job #760125) | Cod sursa (job #170556) | Cod sursa (job #2279939) | Cod sursa (job #891838) | Cod sursa (job #1921889)
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("aprindere.in");
ofstream g("aprindere.out");
short n,m,a[1005];
int timp;
int main()
{
f>>n>>m;
for(short i=0;i<n;++i)
f>>a[i];
for(int i=1;i<=m;++i)
{
int c,nc,t,x;
f>>c;
if(a[c]==0)
{
f>>t;
timp+=t;
f>>nc;
for(short j=1;j<=nc;++j)
{
f>>x;
if(a[x]==0)
a[x]=1;
else
a[x]=0;
}
}
else
{
f>>t>>nc;
for(short j=1;j<=nc;++j)
f>>x;
}
}
g<<timp;
return 0;
}