Cod sursa(job #2656797)

Utilizator VNohaiNohai Vlad-Auras VNohai Data 8 octombrie 2020 18:51:25
Problema Aprindere Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.73 kb
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>

using namespace std;

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

int main()
{
    bool v[1001];
    int costuri[1001], af=0, cost;
    vector <int> buton[1001];
    int n, m, poz, k;
    fin>>n>>m;
    for(int i=1; i<=n; i++)
    {
    fin>>v[i];
    }
    for(int i=1; i<=m; i++)
    {
    fin>>poz>>cost>>k;
    costuri[i]=cost;
    for(int j=1; j<=k; j++)
    {
    int a;
    fin>>a;
    buton[poz].push_back(a);
    }
    }
    for(int i=1; i<=n; i++)
    {
    if(v[i]==false)
    {
    af=af+costuri[i];
    for(int j=0; j<buton[i].size(); j++)
    v[j]=true;
    }
    }
    fout<<af;
    return 0;
}