Cod sursa(job #1255740)

Utilizator ionut98Bejenariu Ionut Daniel ionut98 Data 5 noiembrie 2014 07:30:10
Problema Aprindere Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.54 kb
#include<fstream>
using namespace std;
ifstream f("aprindere.in");
ofstream g("aprindere.out");
int n,m,c,t,nrc,aux[110];
long cost=0;
bool cam[1001];
int main()
{
    int i,j;
    f>>n>>m;
    for(i=0;i<n;i++)
        f>>cam[i];
    for(i=0;i<m;i++)
    {
        f>>c>>t>>nrc;
        for(j=0;j<nrc;j++)
        {
            f>>aux[j];
        }
        if(!cam[c])
        {
            cost+=t;
            for(j=0;j<nrc;j++)
                cam[aux[j]]=1-cam[aux[j]];
        }
    }
    g<<cost;
    return 0;
}