Advertisement
vitormartinotti

Untitled

Apr 18th, 2024
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. int main() {
  4.     int n, m; scanf("%d %d", &n, &m);
  5.  
  6.     int t[n][m];
  7.  
  8.     for(int i = 0; i < n; i++){
  9.         for(int j = 0; j < m; j++){
  10.             scanf("%d", &t[i][j]);
  11.         }
  12.     }
  13.  
  14.     int somaL[n];
  15.     for(int i = 0; i < n; i++){
  16.         somaL[i] = 0;
  17.     }
  18.  
  19.     for(int i = 0; i < n; i++){
  20.         for(int j = 0; j < m; j++){
  21.             somaL[i] += t[i][j];
  22.         }
  23.     }
  24.  
  25.     long long int menor = 100000000;
  26.     int resp;
  27.     for(int i = 0; i < n; i++){
  28.         if(somaL[i] < menor){
  29.             menor = somaL[i];
  30.             resp = i;
  31.         }
  32.     }
  33.  
  34.     printf("%d", resp+1);
  35.  
  36. }
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement