fork download
  1. #include<stdio.h>
  2. #include<algorithm>
  3. int a[105][105];int c[10000],b[10000];
  4.  
  5. int max(int n,int p,int b[],int c[])
  6. { int i;
  7. if(n%2==0)
  8. {
  9. std::sort(b+0,b+(p-1));
  10. return b[p-1];
  11. }
  12. else
  13. {std::sort(c+0,c+(p-1));
  14. return c[p-1];}
  15.  
  16. }
  17.  
  18. int main()
  19. {
  20.  
  21. int t,f,p=0;
  22. scanf("%d",&t);
  23. while(t--)
  24. {
  25. int i,k,j,n,b,c;
  26. scanf("%d",&n);
  27.  
  28. for(i=0;i<n;i++)
  29. {
  30. for(j=0;j<=i;j++)
  31. {
  32. scanf("%d",&a[i][j]);
  33. }
  34. }
  35.  
  36. /*if(n==1)
  37.   { b[0]=c[0]=a[0][0];}
  38.   else
  39. {
  40.   b[0]=a[0][0]+a[1][0];
  41.   b[1]=a[0][0]+a[1][1];
  42.   for(i=2;i<n;i++)
  43.   {
  44.   if(i%2==0)
  45.  {p=0;
  46. for(j=0;j<i;i++)
  47. {
  48. c[p]=b[j]+a[i][j];
  49. p++;
  50. c[p]=b[j]+a[i][j+1];
  51. p++;
  52. }
  53. }
  54. else
  55. {p=0;
  56. for(j=0;j<i;j++)
  57. {
  58.  b[p]= c[j]+ a[i][j];
  59. p++;
  60. b[p]=c[j]+a[i][j+1];
  61. p++;
  62. }
  63. }
  64. }
  65. }
  66. if(n%2==0)
  67. j=max(n,p);
  68. else
  69. j=max(n,p);
  70. printf("%d\n",j);*/
  71. //j=a[0][0];b[0]=j;
  72. printf("%d\n",a[0][0]);
  73. }
  74. return 0;}
Success #stdin #stdout 0s 2852KB
stdin
1
2
1
2 1
stdout
1