func_code_string: #include <bits/stdc++.h>   using namespace std;   int const maxn = (int)1e4 + 111;   int const inf = (1 << 30) - 1;   int k;   int a[4];   int t[4];   int d[maxn][4];   int first[maxn][4];   int main() {     cin >> k;     for (int i = 1; i <= 3; i++) cin >> a[i];     for (int i = 1; i <= 3; i++) cin >> t[i];     for (int j = 1; j <= 3; j++) {       for (int i = 1; i <= k; i++) {         int v = -1;         for (int q = 1; q <= a[j]; q++) {           if (v == -1 || first[q][j] < first[v][j]) {             v = q;           }         }         d[i][j] = max(d[i][j - 1], first[v][j]) + t[j];         first[v][j] = d[i][j];       }     }     cout << d[k][3] << endl;     return 0;   }   