Mai intai trebuie sa te autentifici.
Cod sursa(job #875670)
Utilizator | Data | 10 februarie 2013 16:59:18 | |
---|---|---|---|
Problema | Aprindere | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.86 kb |
// aprindere.cpp : Defines the entry point for the console application.
//
//#include "stdafx.h"
#include "fstream"
using namespace std;
struct intrerupator
{
int timp;
int actiune[100];
int nract;
}intr[1000];
int suma;
int main()
{
ifstream f("aprindere.in");
ofstream g("aprindere.out");
int nr_cam,nr_intr,camere[1000];
f>>nr_cam>>nr_intr;
int i,apr=0;
for(i=0;i<nr_cam;i++)
f>>camere[i];
for(i=0;i<nr_intr;i++)
{
apr=0;
int x;
f>>x;
f>>intr[i].timp;
f>>intr[i].nract;
int j;
if(camere[x]==0)
{
apr=1;
suma+=intr[i].timp;
}
for(j=0;j<intr[i].nract;j++)
{
f>>intr[i].actiune[j];
if(camere[intr[i].actiune[j]]==0 && apr==1)
camere[intr[i].actiune[j]]=1;
else
if(camere[intr[i].actiune[j]]==1 && apr==1)
camere[intr[i].actiune[j]]=0;
}
}
g<<suma;
return 0;
}