Cod sursa(job #2897385)

Utilizator AM_PunkMateian Andrei Ilie AM_Punk Data 3 mai 2022 16:43:51
Problema Aprindere Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.7 kb
#include <fstream>

using namespace std;
ifstream fin("aprindere.in");
ofstream fout("aprindere.out");

int n,m,v[1001],tmin;


int main()
{
    fin>>n>>m;
    for(int i=0;i<n;i++)
    {
        fin>>v[i];
    }
    for(int i=0;i<m;i++)
    {
        int c,t,nrc;
        fin>>c>>t>>nrc;
        bool ok=false;
        if(v[c]==0)
        {
            tmin+=t;
            ok=true;
        }
        for(int j=0;j<nrc;j++)
        {
            int x;
            fin>>x;
            if(ok==true)
            {
                if(v[x])
                    v[x]=0;
                else
                    v[x]=1;
            }
        }
    }
    fout<<tmin;
    return 0;
}