Cod sursa(job #2169000)
| Utilizator | Data | 14 martie 2018 13:02:45 | |
|---|---|---|---|
| Problema | Aprindere | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.69 kb |
#include <fstream>
using namespace std;
ifstream f("aprindere.in");
ofstream g("aprindere.out");
struct adda
{
int t,nr;
}v[1001];
int c[1005][1005],n,m,a[1001],ca,i,j,timp;
int main()
{
f>>n>>m;
for (i=0;i<n;i++)
{
f>>a[i];
}
for (i=1;i<=m;i++)
{
f>>ca;
f>>v[ca].t>>v[ca].nr;
for (j=1;j<=v[ca].nr;j++)
{
f>>c[ca][j];
}
}
timp=0;
for (i=0;i<n;i++)
{
if (a[i]==0)
{
timp=timp+v[i].t;
for (j=1;j<=v[i].nr;j++)
{
a[c[i][j]]=1-a[c[i][j]];
}
}
}
g<<timp;
return 0;
}
