Cod sursa(job #3267759)

Utilizator maxtraAlex Deonise maxtra Data 12 ianuarie 2025 11:35:31
Problema Aprindere Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.66 kb
#include <bits/stdc++.h>

using namespace std;

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

int main()
{
    int n, m, v[1002], a, t, c, v2[1002], s = 0;
    bool inchis = 0;
    
    in >> n >> m;
    
    for(int i = 0; i < n; i++)
        in >> v[i];

    for(int i = 0; i < m; i++){
        in >> a >> t >> c;
        inchis = 0;
        
        for(int j = 0; j < c; j++){
            in >> v2[j];
            if(!v[v2[j]])
                inchis = 1;
        }
        if(inchis){
            for(int j = 0; j < c; j++)
                v[v2[j]] = 1 - v[v2[j]]; 
               
            s += t;
        }
        
    }

    out << s;

    return 0;
}