Cod sursa(job #476748)
| Utilizator | Data | 12 august 2010 12:02:36 | |
|---|---|---|---|
| Problema | Nivele | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.52 kb |
#include<fstream>
#include<stack>
using namespace std;
const char iname[]="nivele.in";
const char oname[]="nivele.out";
ifstream f(iname);
ofstream g(oname);
int t,n,x;
stack<int> S;
int main()
{
f>>t;
while(t--)
{
f>>n;
stack<int>().swap(S);
while(n--)
{
f>>x;
while(S.size()&&S.top()==x)
S.pop(),--x;
S.push(x);
}
if(S.size()==1&&S.top()==1)
g<<"DA\n";
else
g<<"NU\n";
}
}
