fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n,i,j;
  6. int sum=0;
  7. cin>>n;
  8. while(n--){
  9. int b;
  10. cin>>b;
  11. int a[b][b];
  12. for(i=0;i<b;i++){
  13. for(j=0;j<=i;j++){
  14. cin>>a[i][j];
  15. }
  16. cout<<endl;
  17. }
  18. for(i=1;i<b;i++){
  19. for(j=0;j<=i;j++){
  20. sum+=max(a[i][j],a[i][j+1]);
  21. }
  22. cout<<endl;
  23. }
  24. cout<<sum;
  25. }
  26.  
  27. return 0;
  28. }
Success #stdin #stdout 0s 4480KB
stdin
1
3
1
2 1
1 2 3
stdout




32773