Cod sursa(job #3274570)

Utilizator tomavladnicolae@gmail.comTomavlad [email protected] Data 7 februarie 2025 10:21:12
Problema Aprindere Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.76 kb
#include <bits/stdc++.h>

using namespace std;
ifstream fin("aprindere.in");
ofstream fout("aprindere.out");
int n,m,bec[1005];
struct vrajeala
{
    int t,c,nrc,a[1005];
} v[1005];
int main()
{
    int i,j,sol;
    sol=0;
    fin >> n >> m;
    for(i = 0; i < n; i++)fin >> bec[i];
    for(i = 0; i < m; i++)
    {
        fin >> v[i].c >> v[i].t >> v[i].nrc;
        for(j = 0; j < v[i].nrc; j++)
            fin >> v[i].a[j];
    }
    for(i = 0; i < m; i++)
    {
        if(bec[v[i].c] == 0)
        {
            for(j = 0; j < v[i].nrc; j++)
                if(bec[v[i].a[j]] == 1)
                    bec[v[i].a[j]] = 0;
                else bec[v[i].a[j]] = 1;
            sol += v[i].t;
        }
    }
    fout<<sol;
    return 0;
}