Cod sursa(job #2489862)
| Utilizator | Data | 9 noiembrie 2019 12:29:32 | |
|---|---|---|---|
| Problema | Aprindere | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.62 kb |
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
ifstream in("aprindere.in");
ofstream out("aprindere.out");
int main() {
int n, m;
in >> n >> m;
vector <int> lights_on(n);
for (int i = 0; i < n; i++) {
in >> lights_on[i];
}
int cost = 0, c, t, nrc, a;
for (int i = 0; i < m; i++) {
in >> c >> t >> nrc;
if (!lights_on[c]) {
cost += t;
}
for (int j = 0; j < nrc; j++) {
in >> a;
lights_on[a] = 1 - lights_on[a];
}
}
out << cost << '\n';
return 0;
}