Cod sursa(job #3178092)

Utilizator Alexbora13Bora Ioan Alexandru Alexbora13 Data 30 noiembrie 2023 23:04:45
Problema Aprindere Scor 5
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.53 kb
#include <bits/stdc++.h>

using namespace std;

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

int n, m, x;
int c, t, nr, s, apasat;

bool stare[1001];

int main()
{
    fin >> n >> m;
    for(int i=0; i<n; i++)
        fin >> stare[i];
    while(m--)
    {
        fin >> c >> t >> nr;
        if(stare[c]==0)
            s+=t, apasat=1;;
        while(nr--)
        {
            fin >> x;
            if(apasat)
                stare[x]=!stare[x];
        }
    }
    fout << s;
    return 0;
}