Pagini recente » Cod sursa (job #1492607) | Cod sursa (job #1638575) | Cod sursa (job #1043830) | Borderou de evaluare (job #1527444) | Cod sursa (job #999322)
Cod sursa(job #999322)
#include <fstream>
using namespace std;
ifstream f("nivele.in");
ofstream g("nivele.out");
int t, n, st[50005];
int main()
{
f>>t;
while (t--)
{
f>>n; int top=0;
for (int i=1; i<=n; ++i)
{
f>>st[++top];
while (top>1 && st[top]==st[top-1])
--top, --st[top];
}
if (top==1 && st[1]==1) g<<"DA\n";
else g<<"NU\n";
}
return 0;
}