aboutsummaryrefslogtreecommitdiffstats
path: root/1672/main.cpp
blob: 50397e9a9f0753883f93719f631f7fa0931f5e95 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include "header.hpp"
#include <algorithm>

class Solution {
public:
  static int maximumWealth(std::vector<std::vector<int>> &accounts) {
    int i_max = 0;
    int sum_max = 0;
    int sum_cur = 0;
    for (int i = 0; i < accounts.size(); ++i) {
      for (int j = 0; j < accounts[i].size(); ++j) {
        sum_cur += accounts[i][j];
      }
      if (sum_cur > sum_max) {
        sum_max = sum_cur;
        i_max = i;
      }
      sum_cur = 0;
    }
    return sum_max;
  }
};

int main(int argc, char **argv) {
  std::vector<std::vector<int>> accounts = {{1, 2, 3}, {3, 2, 1}};
  std::cout << Solution::maximumWealth(accounts);
  return 0;
}