fork download
  1. #include<stdio.h>
  2. int t,n,c[1000],a,b[1000],z=1;
  3. int main()
  4. {
  5.  
  6. scanf("%d\n",&t);
  7. for(int i=0;i<t;i++)
  8. {a=0;z=1;
  9. scanf("%d\n",&n);
  10. for(int j=0;j<n;j++)
  11. {
  12. scanf("%d ",&c[j]);
  13. if(c[j]>n-1)
  14. {
  15.  
  16. z=0;
  17.  
  18.  
  19. }a+=c[j];
  20. }
  21.  
  22. if(a>n)
  23. {
  24. z=0;
  25. }
  26. if(z==0)
  27. {
  28. printf("-1\n");
  29. }
  30. if(z!=0)
  31. { a=0;
  32. for(int j=0;a<n;j++)
  33. {
  34. for(int k=n-1-a;k>n-a-1-c[j];k--)
  35. {
  36. b[k]=j+1;
  37. }
  38. a+=c[j];
  39. }
  40.  
  41.  
  42. {
  43. for(int j=0;j<n;j++)
  44. {
  45. printf("%d ",b[j]);
  46. }
  47. printf("\n");
  48. }
  49. }
  50.  
  51. }
  52. return 0;
  53. }
Success #stdin #stdout 0s 3104KB
stdin
Standard input is empty
stdout
Standard output is empty