summaryrefslogtreecommitdiff
path: root/2022/Day1/main.cpp
blob: 6f9f848ad3824e46843ebff827552595ed812d4a (plain)
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
29
30
31
32
33
34
35
#include<bits/stdc++.h>
using namespace std;

using ll = long long;
using vll = vector<long long>;

#define pb push_back 
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

void solve() {
  string s;
  ll sum = 0;
  ll mx = 0;
  vll v;
  while(getline(cin, s)) {
    if (s.empty()) {
      v.pb(sum);
      sum = 0;
    } else {
      int x = stoi(s);
      sum += x;
    }
  }
  sort(rall(v));
  cout << v[0] + v[1] + v[2] << '\n';
}

int main () {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
  solve();
}