Cod sursa(job #2152967)

Utilizator Alex_BubBuburuzan Alexandru Alex_Bub Data 5 martie 2018 21:29:35
Problema Aprindere Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.55 kb
#include <fstream>

using namespace std;

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

bool v[1001];

int main()
{
    int t, n, nr, sol = 0, c, x, timp;

    fin >> n >> t;

    for(int i = 0; i < n; i++)
        fin >> v[i];

    while(t--) {
        bool ok = false;

        fin >> c >> timp >> nr;

        if(!v[c]) {
            sol += timp;
            ok = true;
        }

        while(nr--) {
            fin >> x;
            if(ok) v[x] = !v[x];
        }
    }

    fout << sol;

    return 0;
}