Cod sursa(job #2698459)
Utilizator | Poinaru-Rares-Aurel RaresPoinaru | Data | 22 ianuarie 2021 10:31:56 |
---|---|---|---|
Problema | Aprindere | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.72 kb |
#include <fstream>
using namespace std;
ifstream fin ("aprindere.in");
ofstream fout ("aprindere.out");
int v[1001];
int main()
{
int n,m,j,i,c,t,nrc,r,tf,ok;
tf=0;
fin >>n>>m;
for (i=0;i<=n;++i)
{
fin >>v[i];
}
for (i=1;i<=m;++i)
{
fin >>c>>t>>nrc;
ok=0;
if (v[c]==0)
{
ok=1;
tf=tf+t;
}
for (j=1;j<=nrc;++j)
{
fin >>r;
if (ok==1)
{
if (v[r]==0)
v[r]=1;
else
v[r]=0;
}
}
}
fout <<tf;
fin.close ();
fout.close ();
return 0;
}