Cod sursa(job #1247206)

Utilizator flore77Simion Florentin flore77 Data 22 octombrie 2014 13:05:35
Problema Aprindere Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.74 kb
#include <iostream>
#include <fstream>
using namespace std;

int main()
{
    ifstream in("aprindere.in");
    int n, m, aprinse[1010], camera, timp, nrCamere, camere[110], i, j, total = 0;
    in >> n >> m;
    for (i = 0; i < n; i++) {
        in >> aprinse[i];
    }
    for (i = 0; i < m; i++) {
        in >> camera >> timp >> nrCamere;
        for (j = 0; j < nrCamere; j++) {
            in >> camere[j];
        }
        if (aprinse[camere[0]] == 0) {
            for (j = 0; j  < nrCamere; j++) {
                aprinse[camere[j]] = !aprinse[camere[j]];
            }
            total += timp;
        }
    }
    in.close();
    ofstream out("aprindere.out");
    out << total;
    out.close();
    return 0;
}