Cod sursa(job #2291913)

Utilizator OctavianVasileVasileOctavian OctavianVasile Data 28 noiembrie 2018 19:26:53
Problema Aprindere Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.79 kb
#include <bits/stdc++.h>
using namespace std;
const int NMAX = 1003;
ifstream fin("aprindere.in");
ofstream fout("aprindere.out");
int n, m, c, t, ind, bec [NMAX], timp [NMAX], nr [NMAX], v [NMAX][NMAX], ans;
int main (){
    fin >> n >> m;
    for (int i = 0; i <= n - 1; i ++)fin >> bec [i];
    for (int i = 1; i <= m; i ++){
        fin >> c >> t >> ind;
        timp [c] = t;
        nr [c] = ind;
        for (int j = 1; j <= ind; j ++)
            fin >> v [c][j];
    }
    for (int i = 0; i <= n - 1; i ++){
        if (bec [i] == 0){
            ans += timp [i];
            for (int j = 1; j <= nr [i]; j ++){
                if (bec [v [i][j]] == 0) bec [v [i][j]] = 1;
                else bec [v [i][j]] = 0;
            }
        }
    }
    fout << ans;
    return 0;
}