Cod sursa(job #1002341)

Utilizator poptibiPop Tiberiu poptibi Data 27 septembrie 2013 16:09:48
Problema Aprindere Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.73 kb
#include <cstdio>
#include <cstdlib>
using namespace std;

const int NMAX = 1005;

int N, M, Status[NMAX], C, T, Nr, X, Ans;

int main()
{
    freopen("aprindere.in", "r", stdin);
    freopen("aprindere.out", "w", stdout);
    
    scanf("%i %i", &N, &M);
    for(int i = 1; i <= N; ++ i) scanf("%i", &Status[i]);
    for(int i = 1; i <= M; ++ i)
    {
        scanf("%i %i %i", &C, &T, &Nr);
        C ++;
        
        bool Change = 0;
        if(Status[C] == 0) Change = 1, Ans += T;
        
        for(int j = 1; j <= Nr; ++ j)
        {
            scanf("%i", &X);
            X ++;
            if(Change) Status[X] = 1 - Status[X];
        }
    }
    
    printf("%i\n", Ans);
    
    return 0;
}