Cod sursa(job #1742506)

Utilizator BogauuuBogdan Ivancu Bogauuu Data 16 august 2016 15:48:01
Problema Aprindere Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.58 kb
#include <fstream>

using namespace std;

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

int n,m,i,c,tc,nr,s,j,x,v[1002];

int main()
{
    fin >> n >> m;
    for (i=0;i<n;i++) fin >> v[i];
    for (i=1;i<=m;i++)
    {
        fin >> c >> tc >> nr;
        if (v[c]==0)
        {
            s=s+tc;
            for (j=1;j<=nr;j++)
            {
                fin >> x;
                if (v[x]==0) v[x]=1;
                else v[x]=0;
            }
        }
        else for (j=1;j<=nr;j++) fin >> x;
    }
    fout << s;

    return 0;
}