Cod sursa(job #3331462)

Utilizator vndianamaria@gmail.comIvan Diana [email protected] Data 28 decembrie 2025 14:15:42
Problema Aprindere Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.17 kb
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <fstream>
using namespace std;
ifstream cin("aprindere.in");
ofstream cout ("aprindere.out");

int a[10001];
struct info {
    bool exists = 0;
    int t = 0;
    int nrc = 0;
    int tr[105];
};
info intr[1001];
int main()
{
   int n, m, timp = 0, t, c, nrc;
   cin >> n >> m;
   for (int  i = 0; i < n; i++) cin >> a[i];
   for (int i = 0; i < m; i++) {
       cin >> c >> t >> nrc;
       
       intr[c].exists = true;
       intr[c].t = t;
       intr[c].nrc = nrc;
       for (int j = 0; j < nrc; j++)
       cin >> intr[c].tr[j];
   }
   for (int i = 0; i < n; i++) {
       if (intr[i].exists) {
           if (a[i] == 0) {
               for (int j = 0; j < intr[i].nrc;j++)
               a[intr[i].tr[j]] ^= 1;
               timp += intr[i].t;
           }
       }
   }
   
   cout << timp;
   
   

    return 0;
}