Mai intai trebuie sa te autentifici.
Cod sursa(job #1064604)
| Utilizator | Data | 22 decembrie 2013 01:52:51 | |
|---|---|---|---|
| Problema | Aprindere | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Teme Pregatire ACM Unibuc 2013 | Marime | 0.73 kb |
#include <fstream>
#include <vector>
using namespace std;
ifstream fin("aprindere.in");
ofstream fout("aprindere.out");
vector<int> lv[1003];
bool v[1003];
int t[1003], N, M;
int main()
{
int i, j;
fin >> N >> M;
for( i = 0 ; i < N; i++)
fin >> v[i];
for( i = 1; i <= M; i++)
{
int c, nrc, time, x;
fin >> c >> time >> nrc;
t[ c ] = time;
for(j = 1; j <= nrc; j++)
{
fin >> x;
lv[c].push_back(x);
}
}
int cost = 0;
for(i = 0; i < N; i++)
if(!v[i]){
cost += t[i];
for(j = 0; j < lv[i].size(); j++)
v[lv[i][j]] = !v[lv[i][j]];
}
fout<<cost;
return 0;
}
