fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int d[1000005];
  5. int max1=-1,max0=-1,t,i,n;
  6. void nhap()
  7. {
  8. int x;
  9. cin>>n;
  10. for (i=1;i<=n/2;i++)
  11. {
  12. cin>>d[i];
  13. d[x]++;
  14. }
  15. }
  16. void tim_max1()
  17. {
  18. t=0;max1=0;
  19. for(int i=1;i<=n;i++)
  20. {
  21. if(d[i]==1) t++;
  22. else t=0;
  23. if(t>max1) max1=t;
  24. }
  25. }
  26. void tim_max0()
  27. {
  28. t=0;max0=0;
  29. for(int i=1;i<=n;i++)
  30. {
  31. if(d[i]==0) t++;
  32. else t=0;
  33. if(t>max0) max0=t;
  34. }
  35. }
  36.  
  37. void xuli()
  38. {
  39. tim_max1();
  40. tim_max0();
  41. if (max1>max0) cout<<"DUONG";
  42. else
  43. if (max1<max0) cout<<"TUNG";
  44. else
  45. if (d[n]==1) cout<<"DUONG";
  46. else cout<<"TUNG";
  47. }
  48. int main()
  49. {
  50. nhap();
  51. xuli();
  52. }
  53.  
Success #stdin #stdout 0.01s 5276KB
stdin
4
2
3
stdout
TUNG