Cod sursa(job #1171717)
Utilizator | Data | 16 aprilie 2014 10:57:01 | |
---|---|---|---|
Problema | Heavy Path Decomposition | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.86 kb |
#include <fstream>
using namespace std;
ifstream fin("6cai.in");
ofstream fout("6cai.out");
int x,m,i,v[100005],nr,last,first,top;
int main()
{
fin >> x >> m;
if (x<=100)
{
for (i=1; i<=m; i++)
{
fin >> nr;
if (nr!=0)
{
last++;
v[last]=nr;
}
else
{
first++;
fout << v[first] << '\n';
}
}
}
else
{
for (i=1; i<=m; i++)
{
fin >> nr;
if (nr!=0)
{
top++;
v[top]=nr;
}
else
{
fout << v[top] << '\n';
top--;
}
}
}
fin.close();
fout.close();
return 0;
}