Cod sursa(job #2495913)

Utilizator dianamichesaRosu Diana Michesa dianamichesa Data 19 noiembrie 2019 23:22:10
Problema Aprindere Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.64 kb
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("aprindere.in");
ofstream g("aprindere.out");
const int N = 1010;
int n, m, v[N], tmp;
int main()
{
    f >> n >> m;
    for(int i = 0; i < n; i ++)
        f >> v[i];
    for(int i = 1; i <= m; i ++) {
        int x, cost, r, y;
        f >> x >> cost >> r;
        if (v[x] == 0) {
            for(int j = 1; j <= r; j ++) {
                f >> y;
                v[y] = !v[y];
            }
            tmp += cost;
        }
        else {
            for(int j = 1; j <= r; j ++)
                f >> y;
        }
    }
    g << tmp;
    return 0;
}