Cod sursa(job #2190456)

Utilizator iandavidroIan David Bocioaca iandavidro Data 30 martie 2018 20:51:50
Problema Aprindere Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.49 kb
#include<bits/stdc++.h>
#define NMAX 1005
using namespace std;

bool b[NMAX];
int n,m,cm,nr,rs, cost,x;
bool u;
int main() {
    ifstream cin("aprindere.in");
    ofstream cout("aprindere.out");
    cin>>n>>m;
    for (int i=0; i<n; i++) cin>>b[i];

    for (int i=1; i<=m; i++) {
        cin>>cm>>cost>>nr;
        if (b[cm]) u=0;
        else b[cm]=1, rs+=cost, u=1;
        for (int j=0; j<nr; j++) {
            cin>>x;
            if (u) b[x]=!b[x];
        }
    }
    cout<<rs;


    return 0;
}