Pagini recente » Cod sursa (job #3272816) | Istoria paginii runda/cnmnarad/clasament | Cod sursa (job #1515877) | Cod sursa (job #1050406) | Cod sursa (job #2214227)
#include <fstream>
#include <vector>
#include <bitset>
using namespace std;
ifstream fin("aprindere.in");
ofstream fout("aprindere.out");
int main() {
int N, M;
fin >> N >> M;
vector <int> Switches;
Switches.resize(N);
vector <bool> bulbs;
bulbs.resize(N);
for (int idx = 0; idx < N; ++idx) {
bool bulb;
fin >> bulb;
bulbs[idx] = bulb;
}
int cost = 0;
for (; M; --M) {
int C, Tc, NRc;
fin >> C >> Tc >> NRc;
bool change = false;
for (int idx = 0; idx < NRc; ++idx) {
fin >> Switches[idx];
if (!bulbs[Switches[idx]])
change = true;
}
if (change) {
cost += Tc;
for(int idx = 0; idx < NRc; ++idx)
bulbs[Switches[idx]] = bulbs[Switches[idx]] ^ 1;
}
}
fout << cost;
}