vitormartinotti

Untitled

May 8th, 2025
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. #define MAXN 1037
  3.  
  4. int m[MAXN][MAXN];
  5. int somaL[MAXN];
  6. int somaC[MAXN];
  7.  
  8. int main(){
  9.     int n; scanf("%d", &n);
  10.    
  11.     for(int i = 0; i < n; i++){
  12.         for(int j = 0; j < n; j++){
  13.             scanf("%d", &m[i][j]);
  14.             somaL[i] += m[i][j];
  15.             somaC[j] += m[i][j];
  16.         }
  17.     }
  18.     int resp = 0;
  19.     for(int i = 0; i < n; i++){
  20.         for(int j = 0; j < n; j++){
  21.             int peso = somaL[i]+somaC[j]-2*m[i][j];
  22.    
  23.             if(peso > resp) resp = peso;
  24.         }
  25.     }
  26.     printf("%d", resp);
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment