Pagini recente » Cod sursa (job #1873096) | Cod sursa (job #804240) | Cod sursa (job #1474014) | Cod sursa (job #192200) | Cod sursa (job #2084934)
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
ifstream fin;
ofstream fout;
int main()
{
int n,i,value,hero,life=0,max=0;
vector<int> element;
fin.open("elmaj.in");
fin>>n;
for(i=0;i<n;i++)
{
if(i==0)
{
fin>>value;
element.push_back(value);
hero=element[i];
life++;
max++;
cout<<hero<<" "<<life<<" "<<max<<"\n";
}
else if(i>0)
{
fin>>value;
element.push_back(value);
cout<<element[i]<<"\n";
if(element[i]!=hero)
{
life--;
cout<<hero<<" "<<life<<" "<<max<<"\n";
if(life==0)
{
hero=element[i];
life++;
max=1;
cout<<hero<<" "<<life<<" "<<max<<"\n";
}
// else if(life!=0)
// {
// }
}
else if(element[i]==hero)
{
life++;
max++;
cout<<hero<<" "<<life<<" "<<max<<"\n";
}
}
}
fin.close();
fout.open("elmaj.out");
cout<<max;
if(max>=n/2-1) fout<<hero<<" "<<max;
else fout<<"-1";
fout.close();
return 0;
}