Cod sursa(job #3377250)

Utilizator MarioApostol2Apostol Mario Andrei MarioApostol2 Data 22 noiembrie 2026 15:15:16
Problema Aprindere Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.91 kb
#include <bits/stdc++.h>

using namespace std;
struct camera {
    int timp;
    int nr;
    int lista[101];
};
int main(){


    ifstream fin ("aprindere.in");
    ofstream fout ("aprindere.out");
    
    int n, m; fin >> n >> m;
    int bec[1001];
    for (int i = 0; i < n; i++)
        fin >> bec[i];
        
    camera a[1001];
    for (int i = 0; i < m; i++) {
        int c, tc, nrc;
        fin >> c >> tc >> nrc;
        a[c].timp = tc;
        a[c].nr = nrc;
        
        for (int j = 0; j < nrc; j++) {
            fin >> a[c].lista[j];
        }
    }
    
    int total = 0;
    for (int i = 0; i < n; i++) {
        if (bec[i] == 0) {
            total += a[i].timp;
            
            for (int j = 0; j < a[i].nr; j++) {
                int aux = a[i].lista[j];
                bec[aux] = 1 - bec[aux];
            }
        }
    }
    fout << total;
return 0;
}