Cod sursa(job #2639519)

Utilizator Darius1414Dobre Darius Adrian Darius1414 Data 2 august 2020 15:28:15
Problema Aprindere Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.49 kb
#include <iostream>
#include <fstream>
#include <algorithm>
#define nmax 1005
using namespace std;
int a[nmax];
  int n,m,i,j,c,t,q,rsp,k;
int main() {


  ifstream f ("aprindere.in");
  ofstream g ("aprindere.out");
  f>>n>>m;
  for (i=0;i<n;i++) f>>a[i];
  for (i=1;i<=m;i++)
  {
    f>>c>>t>>k;
    if (a[c]==0) {
      while (k)
      {k--;
      f>>q;
      a[q]=1-a[q];}
    rsp+=t;
    }
    else
    while (k)
      {k--;
      f>>q;
      }
  }
  g<<rsp;
}