Cod sursa(job #2878923)

Utilizator LucaMuresanMuresan Luca Valentin LucaMuresan Data 28 martie 2022 10:10:52
Problema Aprindere Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.73 kb
#include <bits/stdc++.h>

using namespace std;

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

bitset<1001>v;

int main()
{
    int n, m;
    int time = 0;

    in >> n >> m;

    for (int i=0; i<n; i++)
    {
        bool x;
        in >> x;
        if (x)
            v[i] = 1;
    }

    for (int i=1; i<=m; i++)
    {
        bool ok = false;

        int c, t, nr;
        in >> c >> t >> nr;
        if (v[c] == 0)
        {
            time += t;
            ok = true;
        }

        for (int j=1; j<=nr; j++)
        {
            int pos;
            in >> pos;
            if (ok)
            v[pos] = 1 - v[pos];
        }
    }

    out << time;

    return 0;
}