Cod sursa(job #2116494)

Utilizator robertrRotaru Stefan Robert robertr Data 27 ianuarie 2018 18:14:39
Problema Aprindere Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.75 kb
#include <fstream>
using namespace std;
ifstream f("Aprindere.in");
ofstream g("aprindere.out");
int n,m,st[1001],tc,i,j,x,ok;
struct intrerupator
{
    int ex,cost,nrc;
    int v[101];
}a[1001];
int main()
{
    f>>n>>m;
    for(i=0;i<n;i++)
        f>>st[i];
    for(i=1;i<=m;i++)
    {
        f>>x;
        a[x].ex=1;
        f>>a[x].cost>>a[x].nrc;
        for(j=1;j<=a[x].nrc;j++)
            f>>a[x].v[j];
    }
    for(i=0;i<n;i++)
    {
        if(st[i]==0)
        {
            tc+=a[i].cost;
            for(j=1;j<=a[i].nrc;j++)
            {
                if(st[a[i].v[j]]==0)
                    st[a[i].v[j]]=1;
                else st[a[i].v[j]]=0;
            }
        }
    }
    g<<tc;
    return 0;
}