Cod sursa(job #1674397)

Utilizator sandupetrascoPetrasco Sandu sandupetrasco Data 4 aprilie 2016 17:19:17
Problema Aprindere Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.75 kb
#include <bits/stdc++.h>
#define MOD 666013
#define ll long long
using namespace std;
int N, M, C, T, NR[1041], cnt, X;
bool u[1041];
void citeste(){
    cin >> N >> M;
    for(int i = 0; i < N; i++) cin >> u[i];
}

void rezolva(){
    for(int i = 1; i <= M; i++){
        cin >> C >> T >> X;
            for(int j = 1; j <= X; j++) cin >> NR[j];
        if (!u[C]){
            cnt += T;
            u[C] = 1;
           for(int j = 1; j <= X; j++) 
                 u[NR[j]] = !u[NR[j]];
        }
    }
    cout << cnt;
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);    
    assert(freopen("aprindere.in","r", stdin));
    assert(freopen("aprindere.out","w", stdout));
    citeste();
    rezolva();
    return 0;
}